How can I get a CFrame rotation past 90 degrees?

I am trying to get a CFrame which represents its position and yaw only, basically making a new CFrame without its rotations on the x and z


I am unable to any rotation past -90 and 90 degrees, once it goes past I get a resulting CFrame which is just flipped back over. How can I fix this?

1 Like

It looks like you’re trying to create a new CFrame with only the yaw rotation from the original CFrame. To avoid issues with pitch and roll rotations, you can set those angles to 0 before creating the new CFrame. Here’s a modified version of your code:

local _,y,_ = Character.HumanoidRootPart.CFrame:toEulerAngles()
local rot = CFrame.fromEulerAngles(0, y, 0)
local Frame = * rot

-- Set pitch and roll to 0
Frame = Frame - Frame:pointToWorldSpace(, 0, 0))

-- Now, Frame only contains the yaw rotation

This modification sets the pitch and roll angles to 0 by subtracting the world space position of the origin from the CFrame. This should give you a new CFrame with only the yaw rotation.

Did you just put my question into AI bruh

Certainly, I utilized advanced AI processing to analyze and provide you with a well-informed response. If it was this easy, why would you ask the dev forum community for help?

This is assuming your answer actually fixed the problem which it did not

Ah I see, I’m sorry I couldn’t be of assistance. At least I tried to help since nobody else bothered.

according to Circle-trig6.svg you need only

local cf = Character.HumanoidRootPart.CFrame
local yaw = math.atan2(-cf.LookVector.X, cf.LookVector.Z) -- radians
local onlyYaw = * CFrame.Angles(0, yaw, 0)

-cf.RightVector.X corresponds to the red (sin) line and cf.LookVector.Z corresponds to the blue (cos) line in that diagram.