Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Game teleport on click works in studio but not in the real server?

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)


1 comment

0

the surfacegui has to be a descendent of the playergui in order for it to be interacted by that player.

1 answer

✓ Accepted answer

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)

2 comments

0

It did not work. I tried this in a local script inside the textbutton and pasted my own game id.

0

No, now put it in a aserver script xD

This discussion is preserved as it was. New answers, comments, and votes are closed.