Teleporter GUI doesn't work

Hi, I’m creating a main menu, and I created a button that teleport’s you when you click it, but it doesn’t do anything.

Anotación 2020-05-27 213814

1 Like

Do you mean:

game.Players.LocalPlayer.Character.Torso.CFrame

It still not working :confused:

Hiya, when working with GUI try and use local scripts. Paste what I’ve written down below inside of a local script inside of the button, and change the variables around.

local Player = game.Players.LocalPlayer
local Character = Player.Character
local PlaceToTeleport = game:GetService("Workspace"):FindFirstChild("PART_TO_TELEPORT_TO")

script.Parent.MouseButton1Click:Connect(function()
Character:MoveTo(PlaceToTeleport.Position)
end)

Maybe you have to define it as a variable first, because sometimes the character loads in after you click the button which makes the character nil and cause an error.

local player = game:GetService(“Players”).LocalPlayer
local Character = player.Character
if not Character then Character = player.CharacterAdded:Wait() end

Character.CFrame = — the CFrame

It works!!! Thank you very mutch :smiley:

Additionally, you should add @VegetationBush’s line of code right below the second line. This is important because sometimes the Character doesn’t always load in immediately and will return nil causing your script to break.

Anotación 2020-05-27 215545 Like this??

Perfect, great job. That should work as intended!

1 Like