Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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)


0
the surfacegui has to be a descendent of the playergui in order for it to be interacted by that player. DragonODeath 50 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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)
0
It did not work. I tried this in a local script inside the textbutton and pasted my own game id. Boogieboon 30 — 8y
0
No, now put it in a aserver script xD XToonLinkX123 580 — 8y
Ad

Answer this question