How to rotate orientation on one axis only using CFrame.LookAt

Hiya! I’ve been wanting to make a top down camera script and it’s been pretty simple so far but I hit a roadblock and that is that I need to only rotate the players humanoidrootpart on the Y axis but using CFrame.LookAt it’s rotating to look at the mouse on all axis.

The player rotation code:

	camera.CFrame = (char.HumanoidRootPart.CFrame + offset) * CFrame.Angles(math.rad(-90), 0, 0)
	char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position, mouse.Hit.p) -- rotation on all axis!

I would really appreciate help with this!


I had actually done something similar and this is what worked for me.,, HumanoidRootPart.Position.Y, Mouse.hit.Position.Z))


This works! Only problem I have now is that the player spins very quickly. Any idea on how to fix this?

You can make a tween and make the speed to your choice. (The number inside )

local TweenService = game:GetService("TweenService")

local RootRotationTween = TweenService:Create(HumanoidRootPart,,{CFrame =,, HumanoidRootPart.Position.Y, Mouse.hit.Position.Z))})

You have to put the last two lines in the loop since the tween being created would need to use the current updated Root position and Mouse position.

1 Like

Thank you so much for the well thought out reply but I actually found the problem! I used instead and that seemed to fix the problem.

camera.CFrame = + offset) * CFrame.Angles(math.rad(-90), 0, 0)

Funny thing is, now the player isn’t moving lol

Nvm fixed that! I just changed the rotation of the camera from -90 to -89. This seemed to do the job… I’m still kinda confused why it fixed it though.

1 Like