Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my teleport GUI work properly?

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

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)

1 comment

0

Also might wanna make a few changes when you do make this a script, like not reffering to localplayer.

This discussion is preserved as it was. New answers, comments, and votes are closed.