I am using the teleport service. This is a normal script placed inside of the textbutton in the surfaceGui. I am not quite sure why it is not responding.
script.Parent.MouseButton1Down:connect(function() game:service("TeleportService"):Teleport(MYGAMEIDHERE) end)
This is the script. It's pretty simple
local player = game.Players.LocalPlayer local GameId = YourGameIdHere script.Parent.MouseButton1Down:connect(function() game:service("TeleportService"):Teleport(GameId, player) end)
You need to declare the player, because teleportService use two parametre, the first parametre is the game Id for know where the player will go and the second is the player for know wich player will be teleport. Put it in a LocalScript for declaring the player with no error !
script.Parent.MouseButton1Down:connect(function(player) game:service("TeleportService"):Teleport(MYGAMEIDHERE, player) end)
The teleport method needs to know who to teleport. However, because your surface gui is not under a playerGui folder, it can't tell who clicked. To get around this, put the surfaceGui in StarterGui, and set the "Adornee" property to the brick you want.