Make arms and head follow mouse

How could I do this? I am trying to make the arms and head move a little bit towars the mouse so then the gun can aim properly in 3rd person.
Here is an example of this in action in another game ( strucid )

If anyone could help would mean a lot!

4 Likes

What you’re looking for is Motor6D.C0. This property allows you to set the offset of a part relative to another part in a rig. If you want to make the head look in the direction the camera is looking, I believe you can do the following:

local cameraLook = workspace.CurrentCamera.CFrame.LookVector
player.Character.Head.Neck.C0 = CFrame.new(Vector3.new(), cameraLook) -- Creates a CFrame that looks in the same direction as the camera

You can also raycast from the camera in the lookvector direction to find the surface that the gun should be aiming at, then just make the neck’s C0 aim at that instead of in the direction of the camera.

8 Likes

You can use Mouse.Hit and Humanoid.TargetPoint instead of Ray casting



1 Like

I wouldn’t use Humanoid.TargetPoint as it was mainly used for the click to move feature back before 2012, but Mouse.Hit I would use.

2 Likes

Why my head goes to torso?

You need to get Y offset by doing this :

local neckOffset = neck.C0.Y

This is the result when I put that code. "Y cannot be assigned to ".