# Orientation converting to local Axis for some reason?!

``````block.CFrame = CFrame.new(endPos) * CFrame.Angles(math.rad(block.OrientationVal.Value.X), math.rad(block.OrientationVal.Value.Y), math.rad(block.OrientationVal.Value.Z))
``````

If OrientationVal = 90, 90, 0 then the parts orientation is 0, 90, 90 for some reason, and then if i set it to 90,270,0 the part is at 0, -90, -90, so it seems that parts are turning in a relative axis.

1 Like

Use CFrame.fromOrientation. CFrame.Angles is different.

Theyâ€™re actually exactly the same.

I recommend against CFrame.Angles though, I would recommend using the CFrame matrix where possible.

``````local newAngleCFrame = someCFrame
local newPosCFrame = CFrame.new(endPos)
block.CFrame = CFrame.new(endPos.X, endPos.Y, endPos.Z, select(4, newAngleCFrame:components()))
``````

No, they are different enough to have a chance of producing errors within code with unintentional results.

1 Like

Youâ€™re correct. I had to test it since they didnâ€™t seem to mention the method directly in the info you shared. Iâ€™ll submit a request to fix the documentation later. Thanks for the info.

I still advise against it though. Gimbal lock and all that.

Ok, I am going to try that

CFrame.Angles and CFrame.fromOrientation both suffer from gimbal lock

The difference between Angles and fromOrientation is that angles applies it X then Y then Z which can cause problems because most people think of angles (and its usually more useful) as being applied in the Y then X then Z order

The â€śorientationâ€ť property functions the same as the Y X Z or fromOrientation order while the rotation property is applied in the normal X Y Z order

90,90,0 applied in XYZ order would look like: pitch up 90 degrees then yaw over 90
https://gyazo.com/af3054c2a3a67ac41b9cae590c42f484.mp4
You can see this results in an orientation value of 0,90,90 simply because euler angles suck
https://gyazo.com/62efa18df86b9f70626c02456bf8a45d.mp4
Applying the angles in the order of Y X Z manually you see you get the intended results

Unless you want to learn quaternions youâ€™re probably gonna have to deal with these annoying euler angle problems so Itd be best to familiarize yourself with them

I use neither quaternions nor Euler if I can help it, I use Robloxâ€™s impressive CFrame functions (fromAxisAngle anyone?) and let them take care of it for me. But my issue is that the developer hub says the two functions do the same thing, which as I learned is definitely wrong.

Edit: Oh right, I froget that fromEulerAnglesYZX is a thing and I mis-read it. This is all on me then. smh