I've been trying to make some script for making the gun look to the mouse (It's in first person) for a couple of days now. I was able to get to it work fine until it starting rotating weirdly when I look at the ground, and it rotated all the way when I looked at the sky. So I tried using clamps to get to stop and it did helped a little bit but not a lot. I have no idea what other way to fix it and some help would be great (One way to help is how clamps works, I just tried putting random value to see if it would work)
Here's the snippet of code I've used
