Spawn makes character face wrong direction

Hello Devs! I have this problem that the spawn faces the wrong way, I tried fixing it with the CFrame as in the code. I know where the problem is but don’t know how to fix it since I am not an expert programmer.

The script is here:

game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"

local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Checkpoint"
Checkpoint.Value = 0

Player.CharacterAdded:Connect(function(Character)
	repeat wait() until Player.Character ~= nil
	local checkpoint = workspace.Checkpoints:FindFirstChild(Checkpoint.Value)
	Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.position + Vector3.new(0,2,0))
end)

end)

This is where the problem is:

Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.position + Vector3.new(0,2,0))

Any help would be highly appreciated!

9 Likes

The absolute quickest fix to this is to orient your Front-face of the Spawn the correct way. Characters always spawn in the front-facing direction of the SpawnLocation. If you do that, you don’t even need to do any weird CFrame tricks.

If that doesn’t help you, you can add a * CFrame.Angles(0, math.rad(180), 0) to your CFrame assignment. This will rotate the character 180 degrees of it’s current rotation.

9 Likes

Thank you for your reply. I tried what you did, but it works only for some spawns and not the rest. The spawns that were 0 degrees turned to 180 degrees and vice versa.

2 Likes

If you use the checkpoints’ CFrame instead of position, you’ll get more consistent behavior as it includes the rotation of the part:
HumanoidRootPart.CFrame = checkpoint.CFrame + Vector3.new(0, 2, 0)

Additionally, you can multiply that CFrame with the CFrame.Angles I wrote in my previous post if the rotation is still off. But using the checkpoints’ CFrame you really just need to rotate the checkpoints the right way to fix your issue.

7 Likes

Ohhh, I see where you are going. Ok, I will try that. Thank you!

Edit: It works, thanks!

1 Like

You should mark his reply as a solution

4 Likes