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

How do I make people face a certain direction when they respawn on a checkpoint?

Asked by 2 years ago

I finally got my checkpoint script working but when you respawn, you're always facing the same direction. Here is my script:

game.Players.PlayerAdded:Connect(function(plr)
    local stage = plr:WaitForChild("leaderstats").Stage
        plr.CharacterAdded:Connect(function(char)
        repeat wait() until plr.Character ~= nil
        wait(0.01)
        local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
        char:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,5,0), checkpoint.Position)
        char:FindFirstChild("HumanoidRootPart").Orientation = Vector3.new(0,0,0)
        wait(0.1)
    end)
end)

2 answers

Log in to vote
0
Answered by 2 years ago

[MARK THIS AS ACCEPTED IF THIS WORKS]

You can fix this by first having the correct rotation but not position and then fixing the position.

THE SCRIPT:

game.Players.PlayerAdded:Connect(function(plr)
    local stage = plr:WaitForChild("leaderstats").Stage
    plr.CharacterAdded:Connect(function(char)
        repeat wait() until plr.Character ~= nil
        wait(0.01)
        local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
        char:FindFirstChild("HumanoidRootPart").CFrame = checkpoint.CFrame
        char:FindFirstChild("HumanoidRootPart").Position = Vector3.new(checkpoint.Position.x, checkpoint.Position.y + 5, checkpoint.Position.z)
        wait(0.1)
    end)
end)
0
Tysm for the help! I accepted the answer because it worked, the character faces the right way now. The only thing is the camera still faces the wrong direction. If there is a way to fix that please let me know, thanks BunjiBloxxer 51 — 2y
0
Nevermind about what I said above, the camera only faces the wrong way when you play in studio, not the actual game. BunjiBloxxer 51 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Hey, maybe all you need to do is rotate the checkpoint.

0
No I tried that before I asked the question lol BunjiBloxxer 51 — 2y

Answer this question