I have made this script that on a click of a surface GUI the player will be teleported to a game. This is a regular script inside of a text button. Whenever I test it in studio on play solo it works. But when I join a server there is no success. When I try it in play solo as a local script it does not work, nor in a regular server. Please help me and thank you in advanced.
print("Works here") script.Parent.MouseButton1Down:connect(function() print("Works Here2") game:service("TeleportService"):Teleport(265123738, game.Players.LocalPlayer) print ("Made it this far3") end)
Oh, I found why it was not working, because the parent of your "SurefaceGui" is on the Part and on the Workspace so you'll need to put it in a server Script now.
here the code fix:
local GameId = YourGameIdHere game.Players.PlayerAdded:connect(function(player) script.Parent.MouseButton1Down:connect(function() game:service("TeleportService"):Teleport(GameId, player) end) end)