Y-axis turns of the character do not work well

Character turns with any weapon do not work well and it is not clear why. When walking in the opposite direction with a weapon, the character is pushed a short distance and twitches very strongly. Please help me with this problem.

Rotation script:

RunService = game:GetService('RunService')
Players = game:GetService('Players')
Player = Players.LocalPlayer
Mouse = Player:GetMouse()
Char = Player.Character
if not Char then
	Char = Player.Character

RootPart = Char:WaitForChild('HumanoidRootPart')


	local MousePos = Mouse.Hit.p

	local lookToPosVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)

	RootPart.CFrame = CFrame.new(RootPart.CFrame.p,lookToPosVector)


The script is taken from here:

Try updating the CFrame property of a BodyGyro instead, that might smoothen the look a bit. You can also remove its max Y torque so it only applies force on the X and Z axes.

The character moves slightly differently than the direction of the camera

If you bind the rotation update to RenderStepped instead of Stepped it should eliminate the weird turning. Also you should disable Humanoid.AutoRotate so the humanoid doesn’t turn towards walking direction automatically.