Camera unexpectedly rotates on Z-Axis...

I trying to create a mouse look script I used the following:

		Vector2 vMousePosition = new Vector2();
		Vector3 vMouseMove = new Vector3();
		Vector3 vTurn = new Vector3();
		
		float vLookX = camMain.transform.localRotation.eulerAngles.x;
		float vLookY = camMain.transform.localRotation.eulerAngles.y;
		float vLookZ = camMain.transform.localRotation.eulerAngles.z;
		
		if (vLookX > 180f) vLookX = vLookX - 360f;
		if (vLookY > 180f) vLookY = vLookY - 360f;
		
		vLookX = vLookX * -1f;
		
		float vMinX = -10f;
		float vMaxX = 10f;
		float vMinY = -10f;
		float vMaxY = 10f;
		
		vMousePosition = Input.mousePosition;
		
		// Mouse-based control
		vMouseMove.x = vMousePosition.x - vDelta.x;
		vMouseMove.y = vMousePosition.y - vDelta.y;
		
		float maxDist = 1.0f / Mathf.Min(Screen.width * 0.8f, Screen.height * 0.8f);
		
		if(vLookX > 75f) vMaxY = 0f;
		if(vLookX < -45f) vMinY = 0f;
		if(vLookY > 115f) vMaxX = 0f;
		if(vLookY < -115f) vMinX = 0f;
		
		Debug.Log(vLookX + " -- " + vLookY + " -- " + vLookZ);
		
		vTurn.x = Mathf.Clamp(vMouseMove.y * maxDist, vMinY, vMaxY) * -1f;
		vTurn.y = Mathf.Clamp(vMouseMove.x * maxDist, vMinX, vMaxX);
		vTurn.z = 0f;

		//camMain.transform.localRotation.Set(vTurn.x, vTurn.y, 0f, 0f);
		camMain.transform.Rotate(vTurn, Space.Self);
		camMain.transform.localRotation.eulerAngles.Set(vLookX, vLookY, 0f);
		camMain.transform.localRotation.SetLookRotation(new Vector3(0f, 0f, 0f),Vector3.up);

However, the camera keeps rotating on the z-axis…

I have no idea why. Is there anyway to lock the z-axis on the camera?

Instead of setting the Z axis to 0f on your localRotation try setting it’s Z axis to itself, a transform.localRotation.z = transform.localRotation.z type deal.