Locking the cameras Y axis in pause

So in my pause menu I have found out how to lock everything I can exept for the cameras Y-axis movement. I’ve looked up all kinds of stuff and cant figure it out. Anyone know what I should do?

Thanks

using UnityEngine;
using System.Collections;

public class pauseMenu : MonoBehaviour {

	public GUISkin myskin;

	private Rect windowRect;
	private bool paused = false, waited = true;
	
	private void Start(){
		windowRect= new Rect(Screen.width /2 - 100, Screen.height /2 -100, 200, 200);
	}

	private void waiting(){
		waited = true;
	}

	private void Update(){
		if(waited)
		if(Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P)){
			if(paused == true)
				paused = false;
			else
				paused = true;	

			waited = false;
			Invoke("waiting",0.3f);
		}
		if (paused == true) {
				//makes cursor appear when in the menu
				Cursor.visible = true;
				//disables player movement
				gameObject.GetComponent<PlayerMovement>().enabled = false;
				//camera cannot look horizontally
				gameObject.GetComponent<MouseLook>().enabled = false;
				//disables shooting
				gameObject.GetComponent<PlayerShooting>().enabled = false;
				
			}
		else {
			//Cursor is not visible when not in the menu
			Cursor.visible = false;
			//Player can move when menu is not up
			gameObject.GetComponent<PlayerMovement>().enabled = true;
			//Camera can look horizontally when menu not up
			gameObject.GetComponent<MouseLook>().enabled = true;
			//Shooting when not in menu
			gameObject.GetComponent<PlayerShooting>().enabled = true;
		}
	}

	private void OnGUI(){
		if (paused)
			windowRect = GUI.Window(0, windowRect, windowFunc, "Pause Menu");
	}

	private void windowFunc(int id){
		//Exits Pause
		if(GUILayout.Button("Resume")){
			paused = false;
		}
		//Options for game
		if(GUILayout.Button("Options")){
			//Audio and Video Settings
		}
		//Quits the game
		if(GUILayout.Button("Exit Game")){
			Application.Quit();
		}
	}
}

You need a reference to the script affecting y rotation, which, IIRC, is on the camera of the FPS asset, one level down from the object your script is apparently on. So, you can use GetComponentsInChildren to grab a reference to it.

It looks as though this script is already a component which goes on your player prefab, which means there’s a better way: Expose public variables of the types of components you need access to, then assign the relevant components from your player prefab to these public variables in the inspector. When this is possible, it’s often preferable to the GetComponent family; less runtime computation and less code.

private bool paused;
public MouseLook mouseLookX; // on this object
public MouseLook mouseLookY; // on the camera, child of this object
public PlayerMovement playerMovement;
// etc

void Update() {
  if (Input.GetKeyDown(KeyCode.Escape)) { TogglePause(); }
}

void TogglePause() {
  paused = !paused;
  mouseLookX.enabled = !paused;
  // etc
}

If you don’t ever need to access these as their specific types, it’d be even more svelte and flexible to expose a public MonoBehavior[] behaviors, populate the array in the inspector by dragging in each component, then loop over them enabling or disabling each according to the new paused value.