CFrame rotation limited on Z

I have a plane gyro, the gyro is rotated by using a Vector2 as a ratio of where the mouse is on the screen.
X being from left to right (negative to positive) and Y being down to up.
My current code is simply this:

gyro.CFrame = gyro.CFrame * CFrame.Angles(math.rad(rate.y * stats.Turn.X), math.rad(rate.X * stats.Turn.Y), 0)

how do I set the rotation of my gyro on the Z axis to 0 and instead replace it with ratio.X * 90 so that they can only bank a maximum of 90 degrees?

1 Like

I want to replace the Z rotation of my bodygyro basically…
How do I do this?

math.rad(math.clamp(input, -90,90))

this should clamp your input between 90 degrees.

1 Like

Your issue is that CFrame.Angles applies your x- and y-rotations in an order that will cause the resultant CFrame to have a non-zero z-orientation (roll). Replace this with the CFrame.fromOrientation constructor (more info on CFrame constructors here), and use the third argument to input your desired roll value.

1 Like