Hello!

I made a code that would rotate a CFrame while still keeping the other axises relative to the local orientation Ex : (Rotating the `Y`

axis by `math.rad(90)`

would swap the `X`

and `Z`

axis).

It works but only with specific values or else it breaks and I also don’t understand why I need to do some repetitive action whitout which it wouldn’t work.

```
local UserX, UserY, UserZ = (CFrame.fromEulerAnglesYXZ(X, Z, Y) * CFrame.Angles(math.rad(135), 0, 0)):ToEulerAnglesYXZ()
RightShoulder.C0 = CFrame.new(RightShoulder.C0.Position) * (CFrame.fromEulerAnglesYXZ(UserX, UserY, UserZ) * CFrame.Angles(math.rad(-45), 0, 0))
```

I don’t understand why I need to rotate it by `math.rad(135)`

first and then by `math.rad(-45)`

and not just once by `math.rad(90)`

.

Could someone help me?

Thanks !

This is because CFrames are actually matrices. Unlike other math equations such as 9 * 10 and 10 * 9, the order of multiplication or division of a matrix outputs different values. This is because of how matrices are produced. For each column in a matrix, it also affects the entire corresponding row. So, one axis in a CFrame is not just found with one equation, but with multiple (addition / subtraction problems I think). You can see this in action by just swapping 135 and -45, which will produce different results.

But why then changing the values themeselves creates for something that is not even related to what I was trying to do. If I try to add 60 degrees to the -45 then it will rotate it around the Y axis which is what I want but it wont rotate the other axis with it.

Are you accomplishing this by

```
RightShoulder.C0 = CFrame.new(RightShoulder.C0.Position) * (CFrame.fromEulerAnglesYXZ(UserX, UserY, UserZ) * CFrame.Angles(math.rad(-45 + 60), 0, 0))
```

or by doing

```
RightShoulder.C0 *= CFrame.Angles(math.rad(60), 0, 0)
```

after the first equation?

I’m using the first option to do that.

And it should have worked either way if my code was correct.

Because the first method uses simple addition, it does not use the formula involved with finding matrices. Use the second method to affect all axes of a CFrame.

I tried doing this but it does the same thing as the other one. In the end it doesn’t rotate the other axises with it.

```
RightShoulder.C0 = CFrame.new(RightShoulder.C0.Position) * (CFrame.fromEulerAnglesYXZ(X, Z, Y) * CFrame.Angles(0, math.rad(90 + OffsetRotation), 0))
```