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

Why won't my teleport GUI work properly?

Asked by
JipSea 23
3 years ago

I have a game where you can click different checkpoints in a GUI to teleport throughout the map, However; it keeps teleporting players on top of roofs, etc.

I have read about CFRAME's but cannot get it to work properly.

Please help!

local self = script.Parent;
    local Player = game.Players.LocalPlayer;
    local Character = Player.Character or Player.CharacterAdded:wait();

    self.MouseButton1Down:connect(function()
        Character:MoveTo(Vector3.new(42.913, 37.644, -119.341));
    end)

Thank You.

2 answers

Log in to vote
0
Answered by 3 years ago

You must use a local script. Not sure why but the first answer make me feel like your using a serverscript. Also the local script must be inside the textbutton GUI.

script.Parent.MouseButton1Click:Connect(function() -- When MouseButton1 (L Mouse) clicked then function below code
    local plr = game.Players.LocalPlayer -- Getting LocalPlayer (The client which is the player probably you when testing)
    local char = plr.Character -- Getting plr Character
    char:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(0,0,0) -- Set your CFrame position
end) -- Nihao I am chinese

Comment if you dont understand.

Ad
Log in to vote
-1
Answered by 3 years ago

Make sure its a script, also you don't have any touch intrest in your script.

Put this at the very top of the script, and the second line at the very bottom

function onTouched(hit)
script.Parent.Touched:Connect(onTouched)
0
Also might wanna make a few changes when you do make this a script, like not reffering to localplayer. ifreakinlostmyacount 52 — 3y

Answer this question