Help Fixing Object's Rotation When Facing Camera

The behavior I want is where it faces the camera and is cframed every ‘Update’ call but it doesn’t do this weird Z axis rotation based on the camera’s up/down rotation movement.

https://gyazo.com/eb447b40d5f72296e1d8fee484c81c67

What I also find strange is that in that gif it doesn’t show any changes to the Z axis rotation when it is being updated. But when I imitate the same movement after pausing the script it clearly shows the Z axis being rotated.

https://gyazo.com/ef8daafb8b29d85c2dae26aa2250cb78

Would love some help here!

local RunService = game:GetService("RunService")

local A = workspace:WaitForChild("A")
local B = workspace.CurrentCamera

task.wait(2)

local Offset = B.CFrame:ToObjectSpace(A.CFrame)

local function Update()
	local LookAt = CFrame.lookAt( (B.CFrame * Offset).Position, B.CFrame.Position )
	local X, Y, Z = LookAt:ToEulerAnglesXYZ() --// Retrieve X,Y,Z so we can (potentially) limit an axis rotation

--	A.CFrame = CFrame.new((B.CFrame * Offset).Position) * CFrame.Angles(X, Y, Z)
	A.CFrame = LookAt --// Alternative and simpler method, but misbehaves
end

RunService.RenderStepped:Connect(Update)

u need to set the first the (B.CFrame + Offset) to A.Position

Assuming A is the head

Could you rewrite that? I don’t quite understand haha.

local RunService = game:GetService("RunService")

local A = workspace:WaitForChild("A")
local B = workspace.CurrentCamera

task.wait(2)

local Offset = B.CFrame:ToObjectSpace(A.CFrame)

local function Update()
	local LookAt = CFrame.lookAt(A.Position, B.CFrame.Position )

	A.CFrame = LookAt

end

RunService.RenderStepped:Connect(Update)