How to make CFrame rotate on a pivot

I made a camera that follows the cameras torso using CFrame, but I have a problem I can’t fix

The camera works, but it rotates wrong.

image
Is there a way to make it rotate based off of a certain point so it doesn’t look like this?

part.CFrame = CFrame.new(part.Position, Vector3.new(torso.Position.X, part.Position.Y, torso.Position.Z)); this is the script the camera uses.

Well yes there is!

local Offset = Part.CFrame:ToObjectSpace(Pivot)

Part.CFrame = CFrame.lookAt(Pivot.Position, RootPart.Position) * Offset

Let me know if it works.

What should I put for the “Pivot” variable? Should it be something like (0,0,1) or should it be a part?

Its the position you wanna attach the camera to.

I was asleep sorry for the late response.