2D aiming script

Right now i’m developing a 2D game, and i cant figure out the script for the “hand” of my player that lets me aim my gun in direction where my mouse is pointing.

This is “hand” of my character and I made it child of the "body.

I need it so the “arm” can go around the “body” to where my mouse is pointing, so i could aim my gun (right now the gun is not added to the “hand”).I would appreciate any help i get.

Assuming the camera is Orthographic, and that you have a clock-like rotation (i.e. you are not flipping your character), and that the pivot of the ‘hand’ is anchored at the point you want to rotate the hand, and the ‘forward’ of the hand is to the right when the rotation is (0,0,0), you can do:

function Update() {
    var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    var dir = pos - transform.position;
    var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);