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

How do I trigger something by clicking a button on a GUI?

Asked by 10 years ago

I've been wanting to know this because I want to make a teleport menu sort of like in Bulletproof Canyon II on the train system. All I need to know is how to make it so it will teleport the player who clicked the button.

1 answer

Log in to vote
1
Answered by
Discern 1007 Moderation Voter
10 years ago

You would use a function to trigger when someone clicks the button. This could be made with a very small script. You would get the player (By a way of your choice), go to their Character, and use the :MoveTo() method. This is how I would do it.

--LocalScript only!!!!!

button = script.Parent --Change this to where the button is

button.MouseButton1Click:conect(function()
game.Players.LocalPlayer.Character:MoveTo(0,0,0) --Change 0,0,0 to positions.
end)
0
I get that but I'm talking about a GUI button. This script actually is helpful though, I appreciate it! UngracefulUnicorn 40 — 10y
0
This would work in a GUIButton. Just put it directly in the button, change the argument in the :MoveTo() method to your desired position, and it will work just the way you wish. :) Discern 1007 — 10y
0
Thanks so much! I thought it would be much more confusing than this. UngracefulUnicorn 40 — 10y
0
It would be if the Player didn't have a Character property. And NP :) Discern 1007 — 10y
View all comments (3 more)
0
I just tried this and it doesn't seem to work. The output doesn't say there is any errors but when I test it in Play Solo it doesn't move my character. Do you know why? UngracefulUnicorn 40 — 10y
0
Because the script won't work in Play Solo. It only works in servers. Discern 1007 — 10y
0
Oh. Thanks for letting me know UngracefulUnicorn 40 — 10y
Ad

Answer this question