how to lock the z axis rotation

Hi I am somewhat new to Unity and I have a problem, I want to lock all rotation movement for my camera, I was given a script that made it possible for me to lock the x and y axis but not the z please can you help me. Here is the script.

using UnityEngine;

public class Camera_FPS : MonoBehaviour
{
public Vector2 rotationLimit; //Limit for the vertical rotation of the camera. X is higher limit, Y is lower limit.
public float rotationSpeed = 600.0f; //Vertical rotation speed of the camera
public bool invertY = true; //Invert vertical rotation
public bool headBobEnabled = true; //Enables/disables head bobbing
public Vector2 headBobDistance = new Vector2(0.2f, 0.3f); //The distance the camera travels in the y-axis for the headBobbing effect
public float headBobSpeed = 5.0f; //Speed at which the player’s head bobs

private Vector3 initialLocalPos; //Starting local y-position of camera
private float rot; //Stores the rotation value incremented by mouse movement in the y-axis
private Transform t; //Reference to the transform component of the game object

public void Awake()
{
	t = transform; //Cache transform component
	initialLocalPos = t.localPosition; //Store initial local position of the camera
}

public void Update ()
{
	//Update rotation
	rot += Input.GetAxis("Mouse Y") * rotationSpeed * ((invertY) ? -1 : 1) * Time.deltaTime;
	if(rot < rotationLimit.y) //Check for lower limit
		rot = rotationLimit.y;
	if(rot > rotationLimit.x) //Check for upper limi
		rot = rotationLimit.x;
	t.localRotation = Quaternion.AngleAxis (rot, Vector3.right); //Apply rotation to transform
	
	
	//Head bobbing
	if(headBobEnabled)
	{
		//Calculate percentage of blend between stationary and bobbing camera positions
		float percentage = Mathf.Min(1, Mathf.Abs(Input.GetAxis("Vertical")) + Mathf.Abs(Input.GetAxis("Horizontal")));
		
		//Calculate desired x position
		float desiredPosX = initialLocalPos.x + headBobDistance.x * Mathf.Sin(Time.time * headBobSpeed + Mathf.PI/2);
		//Blend between stationary and desired x position
		float newX = (initialLocalPos.x * (1 - percentage)) + (desiredPosX * (percentage));
		
		//Calculate desired y position
		float desiredPosY = initialLocalPos.y + headBobDistance.y * Mathf.Sin(Time.time * 2 * headBobSpeed);
		//Blend between stationary and desired y position
		float newY = (initialLocalPos.y * (1 - percentage)) + (desiredPosY * (percentage));

		t.localPosition = new Vector3( newX, newY, t.localPosition.z);
	}
}

}

Everyone… Much easier than locking an axis… I have wasted too much time on this, trying to calculate the angle and solve the BS… Apparently Quaternion.LookRotation, does this without having to work about correcting angles, or flipping! Amazing! Unity - Scripting API: Quaternion.LookRotation
Hope this helps:
private void SetRotationFromWorldPoint(Transform trans, Vector3 worldPoint)
{
Quaternion currentRotation = trans.rotation;
currentRotation = Quaternion.LookRotation(worldPoint);
trans.rotation = currentRotation;
}

Look at these links:
“How would I lock a desired axis”

“How to set a single axis rotation of a gameobject”