Obby Teleport help

How can i teleport players? (Im learning CFrame so i know im bad at this)

local obbyteleport = game.Workspace.ObbyTP
local player = game.Players.LocalPlayer


script.Parent.Touched:Connect(function()
	player.Character.HumanoidRootPart.CFrame = obbyteleport.CFrame
end)

Is this a normal script inside of the part? If so then do this. Game.Players.LocalPlayer does not work in a normal script because the game doesn’t know which player you are referencing, the only reason it works in a local script is because the local script is a descendant of the player, so it can find which player is it’s ancestor. In this script, we check if the thing that touched the teleport brick is a body part, if it is, we get the character by referencing the part’s parent.

local obbyteleport = game.Workspace.ObbyTP

script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
	         hit.Parent.HumanoidRootPart.CFrame = obbyteleport.CFrame
        end
end)
1 Like

And instead of doing
hit.Parent.HumanoidRootPart.CFrame = obbyteleport.CFrame
you can do
hit.Parent:MoveTo(obbyteleport.Position)

whats the difference? I thought moveto tries to make your character actually walk to the selected position or something.

no that’s a property of humanoid