# How to use CFrames to match another part's orientation on X and Z axis?

I need a part that matches another part’s orientation on X and Z axis only.
I currently have this:

``````part0.CFrame = part0.CFrame:ToWorldSpace(part1.CFrame - part1.CFrame.p)
``````

The problem with this method: it will rotate the part on all 3 axis. I only want to rotate it on the X and Z axis.

1 Like

Just use orientation instead.

``````part0.Orientation = Vector3.new(part1.Orientation.X,part0.Orientation.Y,part1.Orientation.Z)
``````

Orientation will rotate the part relative to the world. In my case, I need to rotate the part relative to itself. That’s why I absolutely need to use CFrame, not orientation.

Is this what you’re trying to accomplish? Sorry for the misunderstanding originally, I never use CFrame lol.

``````part0.CFrame = part0.CFrame:ToWorldSpace(part1.CFrame - Vector3.new(part1.CFrame.p.X,0,part1.CFrame.p.Z))
``````

Use CFrame.lookVector. Essentially, it does the same thing your trying to do but has multiple use cases.
Theres also rightVector and UpVector. Which could act as your X, Y, and Z, axis’

Than just use

``````part0.CFrame = part0.CFrame:ToObjectSpace(stuffHere)
``````

You need to elaborate a bit more on what you’re trying to accomplish.

“orientation on X and Z axis” is unclear, because orientation is dependent on the order in which you apply axes rotations.

Is the following interpretation correct?

The LookVectors of `part0` and `part1` should be aligned when viewed from the top down, but `part0` should have its `CFrame.LookVector.Y == 0`, ignoring the Y-component for `part1`'s LookVector.

If not, please correct me with more details

Actually, that doesn’t even make total sense. You’ll need to elaborate.

After days of research, I found that a RocketPropulsion is better than CFrames to solve my problem.