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

Can't teleport character (HumanoidRootPart)? [SOLVED]

Asked by 2 years ago
Edited 2 years ago
Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local stage = plr:WaitForChild("leaderstats").Stage.Value
        local checkpoint = game.Workspace.Checkpoints:FindFirstChild(tostring(stage))
        warn("TELEPORTING TO STAGE ".. tostring(stage))
        local offset = Vector3.new(0,2.875,0) -- for smooth teleporting
        char.HumanoidRootPart.CFrame = workspace.Checkpoints:FindFirstChild(tostring(stage)).CFrame + offset
    end)
end)

Everytime my character loads in I'm supposed to teleport to my checkpoint but the teleportation doesn't happen and there are no output errors... https://imgur.com/a/s0IWXcX

[EDIT: ITS SOLVED LOOK IN ANSWERS BELOW]

1 answer

Log in to vote
0
Answered by 2 years ago

SOLVED! Apparently I just had to wait until the character loads in. So I added this line of code before teleporting:

repeat wait() until char.HumanoidRootPart
Ad

Answer this question