How to make player look to the mouse position?

Hi!

  • Sorry for my English I use translator*
    Hmm… Here there is a tiny problem - R6 do not have UpperTorso, which does not give them the opportunity to bend as well.

I only managed to create a small analog of this animation, but in my example, the entire player is leaning.robloxapp-20210329-1336076.wmv (2.6 MB)

 local Camera = workspace.CurrentCamera

 local Player = game.Players.LocalPlayer

 local Character = Player.Character

 local Root = Character:WaitForChild("HumanoidRootPart")

 local Neck = Root:FindFirstChildOfClass('Motor6D')

local YOffset = Neck.C0.Y

 local CFNew, CFAng = CFrame.new, CFrame.Angles

 local asin = math.asin

 game:GetService("RunService").RenderStepped:Connect(function()

 local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector

 if Neck then

 if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then

 Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)

 elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then

 Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)

 end

 end

 end)

To prevent the player from levitating in the air, you can turn your feet towards the ground(this may seem difficult), but I see this as the only possible option.

I think that in the game that you showed us just turns the hands and head, unlike the animation R15, where the player’s torso turns. robloxapp-20210329-1357037.wmv (1013.2 KB)

5 Likes