How can I aim the pistol to the 3D mouse position?

Hi,
I have created my first ever working gun and animated it with Motor6D, but this gun always shoots straight forward and I want to make the arm with gun aim to the mouse 3D position but I don’t know how to do that. Can someone help?

2 Likes

To get the position in world space (3d position). You can use Mouse and Mouse.Hit (returns a cframe) though this only works on the client. To get a cframe that points toward the 3d position you can do CFrame.new(gun.Position, Mouse.Hit) more info on that here Understanding CFrames

2 Likes

I knew that, I’d rather know how to rotate the arm towards this point

2 Likes

Try setting the Motor6D.C0 to CFrame.new(gun.Position, Mouse.Hit).Rotation i’m not sure if this will work though

1 Like