How to Stop the Random Orientation in my CFrame

Hello! Below I have a CFrame that is used to teleport a player to a specific brick if they die. I wrote it from a tutorial, and now when I die, I face a random direction on the brick I am teleported to, which does not make my game work well. How can I fix this so that I face forward when Cframed?

char:SetPrimaryPartCFrame(CFrame.new(TempCheckpoint.Position + Vector3.new(0, 3, 0)) * CFrame.Angles(0, math.rad(TempCheckpoint.Orientation.Y) + math.rad(90), 0))
1 Like

The Y orientation is calculated by the second value, but you are converting an angle to radians. Just get rid of the math.rad in the Y value and in the math.rad(90):
CFrame.Angles(0, TempCheckpoint.Orientation.Y + 90, 0)

1 Like

CFrame.Angles requires radians not degrees, so the use of math.rad is required.

1 Like

I suspect your problem lies in the fact you are setting the position based on the orientation of target part. I am not an expert on CFrames so happy to be corrected but as I understand it the first argument to the CFrame constructor is just about the position in the world, the rotation is controlled by a second parameter. So rather than multiply the new position by the calculated Angle you should use the rotation parameter of the constructor to set the direction they face.

1 Like