Make character face camera on Y axis?

This might be super simple, but I can’t figure it out. Currently I have it so my character looks where the camera is looking on all axis, how do I make it so the character stays on the ground and rotates only along the Y axis?

while wait() do
	local rot = * (Camera.CFrame - Camera.CFrame.p)
	Character.HumanoidRootPart.CFrame = rot

Have you tried to use orientation?

using orientation will disconnect welds, it’s not an option

Oh, true. I forgot about that.

Don’t set CFrame to rotate the character. This will make you spass out and potentially fling when rotating close to walls. I recommend client-side BodyGyro/AlignOrientation instead.

Get the XZ unit-vector of the camera and use that to form the CFrame rather than the full look-vector


Yeah BodyGyro or AlignOrientation would be better, but here is my solution with cframe anyways.

local SHIFT = math.rad(90) -- math.pi/2

local character = script.Parent
local root = character.HumanoidRootPart

local camera = workspace.CurrentCamera

while wait() do
	local lookVec = camera.CFrame.lookVector
	local angle = -math.atan2(lookVec.Z, lookVec.X) + SHIFT
	root.CFrame = * CFrame.Angles(0, angle, 0)

Yes, I’m using BodyGyro, I only did CFrame as an example here.