I have a pretty simple script that makes the player look at the mouse
-- char is the player's character
local lookAt = Vector3.new(mouse.Hit.Position.X,char.PrimaryPart.Position.Y,mouse.Hit.Position.Z)
char.PrimaryPart.CFrame = CFrame.new(char.PrimaryPart.Position,lookAt)
The issue is that when the player looks at the floor right next to the character, the character starts wildly spinning
You could just use the humanoidrootpart’s upvector in a lookat constructor.
local hit = mouse.Hit.Position
local HumRoot = char.PrimaryPart
local HumCF = HumRoot.CFrame
local lookAt = Vector3.new(hit.X, HumCF.Position.Y, hit.Z)
HumRoot.CFrame = CFrame.lookAt(HumCF.Position, lookAt, HumCF.UpVector)