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
Player.CharacterAdded:Wait()
Char = Player.Character
end
RootPart = Char:WaitForChild('HumanoidRootPart')
RunService.Stepped:connect(function()
local MousePos = Mouse.Hit.p
local lookToPosVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
RootPart.CFrame = CFrame.new(RootPart.CFrame.p,lookToPosVector)
end)
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.
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.