# How to remove specifically the X Orientation from a CFrame

Basically just the title.

I’m a bit of a noob when it comes to CFrame and doing math or adjustments to CFrame, so I’m not really sure how to achieve this.

I am confused about what you mean remove? Do you mean like to set the X orientation to 0 or to make X orientation steady?

I’m trying to get effectively the same result as setting X of Orientation to 0, but via CFrame

This doesn’t seem to work and rotates it all willy-nilly when I tested it in Studio… any other solutions?

1 Like

I mean can’t you set a new variable to 0 and just call it as X in the orientation process?

Can you provide a video or photo of what is happening?

Here’s before I try the solution above:

Here’s after I run this small snippet of code:
`workspace.Part.CFrame = workspace.Part.CFrame*CFrame.Angles(0,1,1)`

Remember, I’m trying to apply this to a model using SetPrimaryPartCFrame, so I can’t just do
`part.Orientation = Vector3.new(0,part.Orientation.Y, part.Orientation.Z)`

The reason why it probably didnt work is because you were multiplying the part’s current Cframe with a Cframe angle. To fix this you can construct a new CFrame then multiply that by `CFrame.Angles` without the X orientation applied, For Example:

``````Part.CFrame = CFrame.new(Part.Position.X, Part.Position.Y, Part.Position.Z) * CFrame.Angles(0,1,1)
``````

This should remove the x orientation of the part and using this with `SetPrimaryPartCFrame` should work too

This also doesn’t work and results in the exact same thing shown in the images above.

That’s weird, it worked for me, Here’s what i did to test:

``````local Part = script.Parent
Part.CFrame = CFrame.new(Part.Position.X, Part.Position.Y, Part.Position.Z) * CFrame.Angles(0,1,1)``````

Consider the problem in that you need to remove the X coordinate of the rotation of the CFrame. In that case, you can break down the rotational component and apply it back on the CFrame.

For this problem, use ToOrientation on a CFrame and it will return you the approximate angles for the X, Y and Z rotational components as a tuple. You can then ignore the X and apply the CFrame back. We will use only the position as the current CFrame so that rotation is ignored, then multiply using an evaluated orientation to get a rotation we want.

The reason why simply multiplying a CFrame by a rotated CFrame constructed from Angles won’t work is because CFrame multiplication is actually treated like addition (the specific wording used is offsetting). In essence, you’re basically adding 0 radians so the X won’t actually turn anywhere.

``````local SomeCFrame = Object.CFrame
local _, RY, RZ = SomeCFrame:ToOrientation()
Object.CFrame = CFrame.new(Object.CFrame.Position) * CFrame.fromOrientation(0, RY, RZ)
``````
26 Likes