Maintaining only Yaw in CFrame

Hi! I’m working on moving some objects with BodyMovers, specifically helicopters. The map I’ll be using them isn’t completely flat, but I want my helicopter to be level in all angles except it’s yaw when taking off. I’m unsure of how to manipulate a CFrame’s rotational matrix so that I can set the goal CFrame of a BodyGyro to it.

In layman’s terms, my issue is that a helicopter will land on an uneven surface and that can mess up the helicopter when it turns on again. I want the helicopter when it starts to use the BodyGyro it has to go straight up and level itself, but not turn in weird ways.

This is an example of what I mean by yaw.

So far I haven’t tried much, as I know I cannot go off of the rotational angles from BasePart.Orientation (as the values aren’t equivalent). Beyond that I don’t fully grasp the concept of the rotational matrix enough to manipulate it. Any help would be appreciated!

If you want to make the helicopter’s gyro rotate to specific angles you can use the the following code

pitch = math.rad(pitchDegrees)
yaw = math.rad(yawDegrees)
roll = math.rad(rollDegrees)

Gyro.CFrame = *CFrame.Angles(pitch, yaw, roll)

If you want to make it rotate the same as the Orientation of the helicopter just replace pitchDegrees, yawDegrees and rollDegrees with the XYZ values of the Orientation property respectively

Thanks for the reply! The orientation angles of the part aren’t the same constructors as a CFrame value, so that wouldn’t work.
I did end up having time to mess with it more, and I found the following code to work (for anyone in the future with this issue).

local y,x,z=part.CFrame:ToEulerAnglesYXZ()