Problem with player facing direction of camera

I am working on a smooth camera script and I have been having issues with making the player face the same direction as the camera. the player rotates all directions, which is not what I want (I only want the left and right direction)

local BodyGryo = Instance.new("AlignOrientation", RootPart)
BodyGryo.Mode = Enum.OrientationAlignmentMode.OneAttachment
BodyGryo.Attachment0 = RootPart.RootAttachment
BodyGryo.Responsiveness = 50
BodyGryo.MaxTorque = math.huge
BodyGryo.MaxAngularVelocity = math.huge

BodyGryo.CFrame = CFrame.lookAt(Camera.CFrame.Position, Camera.CFrame.Position + Camera.CFrame.LookVector)

I found the solution

BodyGryo.AlignType = Enum.AlignType.PrimaryAxisParallel
BodyGryo.PrimaryAxis = Vector3.new(0,0,1)