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

Why won't this tp me to the places?

Asked by 10 years ago

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

Log in to vote
0
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

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)
Ad
Log in to vote
1
Answered by 10 years ago

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!

Answer this question