CFrame X axis becomes inverted

I have a BodyGyro for an aircraft, which I’m trying to set its X orientation to -2 degrees so it’ll face downwards:

-- This is fired on RunService.Heartbeat.
Gyro.CFrame = CFrame.Angles(math.rad(-2), math.rad(Main.Orientation.Y), 0)
local x,y,z = Gyro.CFrame:ToEulerAnglesXYZ()
print(math.deg(x))

It works fine when my aircraft is oriented forwards (betwen 90 and -90 degrees in the Y Axis).
However, when I make the aircraft face backwards, the Gyro’s CFrame points up instead. This is the output (first when I face the front, then the second when I go the other way):

image

Does anyone know why this happens and how I can fix this? Any help is appreciated.

Gyro.CFrame = CFrame.Angles(math.rad(-2), math.rad(Main.Orientation.Y), 0)

Solved it, I didn’t realize I was setting the CFrame to -2 in world space.
This is what I did to rotate the Gyro relative to its current orientation:

Gyro.CFrame = Gyro.CFrame:ToWorldSpace(CFrame.Angles(math.rad(-2), 0, 0))
1 Like