How can I make the player move their camera to where their mouse is?

I am programming a gun system, and I want the bullet to shoot directly where the muzzle is facing. Players can then rotate the gun to align their shots. How would I make it so that when the player moves their mouse/camera, the whole gun moves and the players arms would stay on the gun?