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