Involuntary z-Rotation Change

So I was trying to make an FPS, but I ran into a problem when I tried to make controls. I wrote a script that rotates the camera based on the mouse position. The system works fine when the mouse moves solely along the x-axis and the y-axis, but when I tried to move it diagonally, it changes the z-rotation of the camera as well. Here is the script attached to the camera:

var speed:float=0.25;
var mousex:float=0;
var mousey:float=0;

function Update(){
	if (Input.GetAxisRaw("Horizontal")==1){
	if (Input.GetAxisRaw("Horizontal")==-1){
	if (Input.GetAxisRaw("Vertical")==1){
	if (Input.GetAxisRaw("Vertical")==-1){

I want to change just the x- and y- rotations as they appear in the Inspector tab. I understand that Unity has their own first person control scheme, but I wanted to write my own so that I at least understand what I’m doing. Am I missing something small, or completely headed in the wrong direction? Any help is appreciated!

This is the answer you’re looking for.