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

Why won't this tp me to the places?

This is a local script...I don't know how to send the person who clicked the text button to where the button says

function onClick(plr)
game:GetService('TeleportService'):Teleport(172923794, plr.Character)
end
script.Parent.Clicked:connect(onClick)

2 answers

✓ Accepted answer

First, the Teleport function takes a player as the second argument, not the character.

MouseButton1Click does not pass along any arguments, so you're going to need to define the player somewhere else in the script. In a localscript, you can use game.Players.LocalPlayer.

function onClick()
   game:GetService("TeleportService"):Teleport(172923794, game.Players.LocalPlayer)
end

script.Parent.MouseButton1Click:connect(onClick)

Well, I don't know much about teleporting, but I'm pretty positive that "Clicked" is not a valid event. However, "MouseButton1Click" could be used in its place. So the script would be:

function onClick(plr)
game:GetService('TeleportService'):Teleport(172923794, plr.Character)
end
script.Parent.MouseButton1Click:connect(onClick)

I hope this helped!

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