Log in to vote

How to script a GUI [closed]

Asked by 3 years ago

I want a GUI that is like teleport you to a random location on a map of the script please help out.

Locked by evaera and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.


Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.




Now back to your regularly scheduled Scripting Helpers....




2 answers

Log in to vote
Answered by
Everesty 976
3 years ago

I'm going to assume you already have a gui with some type of a gui button.

So, inside of a local script inside of your button you want to use the MouseButton1Down event.

    -- Teleport the player

Inside of that event, we want to make sure the player's character exists.

    if game.Players.LocalPlayer.Character then
        -- Commense the teleport!

After that, just generate 3 random numbers, with math.random, and use the MoveTo method on the character to move it to that location.

        local x = math.random(-10, 10)
        local y = math.random(-10, 10)
        local z = math.random(-10, 10)
        game.Players.LocalPlayer.Character:MoveTo(, y, z))
Log in to vote
Answered by 3 years ago

Well you could just use this instead, although you'd have to adjust it to make you teleport randomly.

function Click()
script.Parent.Parent.Parent.Parent.Character.Torso.CFrame =,#,#)