Personal advice 1: NEVER use eulerAngles unless you know 101% what you are doing.
Personal advice 2: ALWAYS use Quaternions, might seems work intensive, but prevents the Gimbal Lock
I can tell you why it’s not working:
Line 20 and 24 modify the myEuler variable but you never assign the variables to the transform like you did in lines 12 and 16. So either insert
I dont know about the code but the MouseController script that is attached to the default first person controller comes with all the basic functionality including limiting rotation. I have used it myself, just drag and drop the MouseController script to the player.
in the MouseController script you will see some variable that can be tweaked in the editor to change the sensitivity of the mouse, or limit the viewing angle