So, I'm not gonna lie, this code is from a free model. Nonetheless, it doesn't work. I have a button that; when you click it; **** should **** teleport you to a different map. But it doesn't. here is the code:
script.Parent.MouseButton1Click:connect(function() --what fires all the code local place = script:FindFirstChild("PlaceId") local spawn = script:FindFirstChild("DestinationSpawnName") local placeId local spawnName if place then placeId = place.Value if spawn and spawn.Value then spawnName = spawn.Value game:GetService("TeleportService"):TeleportToSpawnByName(placeId, spawnName) else game:GetService("TeleportService"):Teleport(placeId) end end end)
if anyone can help me, it would be much appreciated.
the int valie "DestinationSpawnName" and "PlaceId" are put into the local script. This local script is put into the button.
Here's what I did and it worked. Instead of using an IntValue I used a string value for the spawn name and a number value for the place Id and it worked.
script.Parent.MouseButton1Click:connect(function() --what fires all the code local place = script:FindFirstChild("PlaceId") local spaw = script:FindFirstChild("DestinationSpawnName") local placeId = nil local spawnName = nil if place then placeId = place.Value if spaw and spaw.Value then spawnName = spaw.Value game:GetService("TeleportService"):TeleportToSpawnByName(placeId, spawnName) else game:GetService("TeleportService"):Teleport(placeId) end end end)