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

My GUI teleporter isn't teleporting the player... can anyone help?

I'm trying to make a GUI button that when clicked teleports the player 40 studs above from wherever they are...

Here's the script I made for the GUI button...

local player = game.Players.LocalPlayer

function onClicked()
	player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame + CFrame.new(0,40,0)
end
script.Parent.MouseButton1Click:Connect(onClicked)

1 answer

✓ Accepted answer

You have to use the Model:MoveTo() function. Also, while using CFrames, to add a CFrame to an already existing CFrame, you have to use * instead of +, but while adding Vector3's to existing CFrames, you have to use +.

local player = game.Players.LocalPlayer

local function onClicked()
	local character = player.Character or player.CharacterAdded:Wait()

	character:MoveTo(character.HumanoidRootPart.Position + Vector3.new(0, 40, 0))
end

script.Parent.MouseButton1Click:Connect(onClicked)

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