'Trying to create enter the gungeon type weapons however stuck on making weapons rotate to face mouse

Im making a game similar to Enter The Gungeon and am working in a similar space to them in unity. I'm using unity 3D and making a 2.5D game to give it the same perspective as gungeon. However I'm trying to make it so the weapon will face the mouse and its not working. Ive tried multiple tutorials and none of them have worked.

The issue is that it changes the rotation of all other axes to 0 when the game is in a top down perspective so I rotated the X of the quad to 90. From my experimenting I need the Y axis to follow the mouse. Unless there is a better way to go about this how can I do this with my current setup?

here's the code ive been using that somewhat worked but it resets all axes but Z.

     using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     
     public class MouseFollow : MonoBehaviour
     {
         
     
     
     
         private void Start()
         {
             
         }
     
         private void Update()
         {
             
             var dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
             var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
             transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
         }
     
        
     
        
     }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source