Trying to set a parts rotation puts the original Z, in the Y spot?

I’m simply trying to set a part cframe, like so

local angles = CFrame.Angles(
   math.rad(90),
   math.rad(0),
   math.rad(22)
)

workspace.PART.CFrame = workspace.PART.CFrame * angles

But for some reason checking the parts orientation isn’t what it should be

image

1 Like

I’m not sure why it’s doing that, is the part’s original orientation set to 0,0,0?

2 Likes

Yeah the part starts out with an orientation of 0 on all axis, im stumped on this, I even tried it with a model and the same thing happens

2 Likes

It could just be a studio issue, I would try restarting

3 Likes

Yeah I just restarted it and the same issue is still happening, got any other ideas?
Has this happened to you before?

2 Likes

Try CFrame.FromOrientation instead. Theres various constructor methods for CFrames regarding rotation and each one applies the rotations in a different order hence the discrepancy.

2 Likes

I just tried all of them and its still giving this weird behavior, I’m not sure what else to do

I think the orientation is applying correctly. My guess is that the axis of the part are flipped, causing the numbers to be flipped.

1 Like

This is the only explanation I could up with for the meantime, I could be wrong but I suppose the orientation is applying first from x then y then z, so imagine moving a block with 0, 0, 0 orientation, first it sets x orientation to 90, so the parts orientation sets respective to its current orientation, that means that now its facing upward, you now change the z, which changes according to the parts orientation, so that its looking upward, and z axis is for front face and back face for part, that means its y axis is changing
Because you are using CFrame, it means that whatever you do to the CFrame, it changes respective to the part’s axis, not the world axis

1 Like

As @red4erik said, one of those ways should help out.
I’m pretty sure you’re running into what’s called ‘gimbal lock’.
For a good explanation just google it.
Basically as @meet_theHAXER said, you’re rotating one axis exactly 90°, which now aligns it with one of the other axes. Now when you try to do anything else to either one of those axes it can mess with the other one instead.

If you use the Search tool up top try searching gimbal lock in the forums. There are quite a few posts that let you know how to fix it.

1 Like

I just ended up just making the parts look at the next one in each position and it worked peffectly!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.