How would I rotate a part to face another part, but only one one axis?

I’ve been trying to make my model face a moving part, but only rotate the model on the z axis.
So far, I have

script.Parent:SetPrimaryPartCFrame(CFrame.new(Root.Position, target.Position))

(Obviously that will not work)

I have tried using many different things, but I cannot put them here because I have already deleted them.

when you’re changing the rotation of the part, keep the x and y points the same but only edit the z, idk how to better explain it (im writing an example btw)

Hi

How would I go about getting the z axis from my CFrame?

(I should have been more specific in my question)

well are you using CFrame.lookAt

Would

CFrame.new(Root.Position, target.Position)).lookAt.Z

work?

1 Like
local face = workspace.FacePart
local char = game.Players.LocalPlayer.Character

face.CFrame = CFrame.lookAt(face.Position, Vector3.new(face.Position.X, face.Position.Y, char.HumanoidRootPart.Position.Z))

2 Likes

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