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

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

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

✓ Accepted answer

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)

7 comments

0

I get that but I'm talking about a GUI button. This script actually is helpful though, I appreciate it!

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. :)

0

Thanks so much! I thought it would be much more confusing than this.

0

It would be if the Player didn't have a Character property. And NP :)

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?

0

Because the script won't work in Play Solo. It only works in servers.

0

Oh. Thanks for letting me know

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