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

Game teleport onclick of a surface Gui textbutton not working?

Asked by 8 years ago

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

3 answers

Log in to vote
1
Answered by 8 years ago
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 !

Ad
Log in to vote
0
Answered by 8 years ago

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.

Log in to vote
-1
Answered by
xuefei123 214 Moderation Voter
8 years ago

Is it not

****Cick not down? Try that.

Answer this question