soo basically i have a thing that depends on the rotation of a part and i noticed if you rotate a part >90 deg around the y-axis it does this
im simply printing this
print(workspace.Part.Rotation.Z)
why does this happen and is there a way to fix it?
1 Like
The issue is that Roblox’s Rotation property uses Euler angles,which can cause gimbal lock and unexpected behavior past 90 degrees on the Y-axis.When Y rotation exceeds 90 degrees,the Z rotation flips to 180 and adjusts other axes,as seen in your output (Z jumping to 180)
To fix this, use CFrame:ToEulerAnglesXYZ() to get consistent angles,try this:
local part = workspace.Part
local x, y, z = part.CFrame:ToEulerAnglesXYZ()
print(math.deg(z))
3 Likes
uhh, it still happens

just printing z directly without a math.rad
wait does rotating it using the build in rotate tool nullify :ToEulerAngleXYZ()?
when you run math.deg
on radians, it’ll turn it into the representation of it in degrees, in this case the Z
is -3.1415927410125732
which is around -180° converted using math.deg
.
isn’t that what you’re looking for?
edit: nvm i just decided to read and i realize why this isn’t the intended result