How to make gun rotate around player based on mouse position

i want the gun to rotate around the player based on the mouse’s position relative to the player like this:

this is my setup for the rotation part:

the gun is offset from the pivot point, which is locked on the player

how can i find the position of the mouse relative to the player and then rotate the gun to point that way?

Vector3 difference = Camera. main. ScreenToWorldPoint(Input. mousePosition) - transform. position;
float rotation_z = Mathf. Atan2(difference. y, difference. x) * Mathf. Rad2Deg;
transform. rotation = Quaternion. Euler(0f, 0f, rotation_z + offset);

MyAARPMedicare Login