How do i lock a part to one axis using CFrame? [nvm i solved it]

So i’m trying to make a character look at a part via CFrame.lookAt and PivotTo(), but i want it to only change the X and Z axis

But i just cannot figure out how to, i tried multiplying the cframe with Cframe.new(1, 0, 1) but that just doesn’t work. I also just tried adding a part and setting the cframe and locking it to one plane, but that didn’t work either

CFrame.LookAt requires two positions

I’m already using that. The problem is that it rotates on all axis and I want it to rotate on one.

When you mean one, do you mean ignoring up?

local targetPosition = targetPart.Position
local characterPosition = character:GetPivot().Position


local lookAtPosition = Vector3.new(targetPosition.X, characterPosition.Y, targetPosition.Z)

local newCFrame = CFrame.lookAt(characterPosition, lookAtPosition)


character:PivotTo(newCFrame)