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

How to make a teleport GUI? I already have a working script.

Asked by 5 years ago

Hi guys, I'm new into scripting and I need your help. I already wrote a working script but now I want to use it with a GUI button.

for i = 1,45 do
wait(.08)
game:GetService('Players').LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(150, 0, 150)
end

Thank you so much for your help!

1 answer

Log in to vote
1
Answered by
vexound 170
5 years ago

First what you want to do is go into StarterGui and insert a ScreenGui. ScreenGui's help to store GuiObjects that can be displayed on the players screen.

Next you want to insert a TextButton (if you want the gui to be text) or a ImageButton (if you want the gui to be an image) into the ScreenGui that we just put in. This button has an event called MouseButton1Click. Basically all this does is when the player fully clicks their left mouse button on the button, it calls a function. By calling a function I just mean that after you click it, it plays a group of code.

Lastly, inside of the button we just added, put inside a local script. This is because PlayerGui is displayed on the client (the player's side of view). Inside the local script we can put:

local button = script.Parent

button.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(150, 0, 150)
end)

In the first line we create a variable for button to know where it is. Next we connect the event MouseButton1Click() to a function. Inside the function we run your previous code for teleporting the character.

Hope this helped! And if it did make sure to upvote and mark my answer! Have a nice day

Ad

Answer this question