Rotate GameObject in 2D Based On Mouse

Let’s say i have a player gameobject with a child gameobject which is a weapon. I want the weapon to rotate based on where the mouse position is.

For some reason it doesn’t rotate at all… But when i go into scene mode while testing, it suddenly appears to be rotated. Am i doing this right?

Note that it’s a 2d game.

 void Update()
    {
        Vector3 mouse = GameCamera.globalCam.camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f));
        Vector3 dir = (mouse - transform.position);

        weapon.gameObject.transform.rotation = Quaternion.LookRotation(dir, Vector3.up);[code]

Any thoughts?

Pleaaaaase

i have AIDS