Boolean is set to true but is unchecked in the inspector

I have a boolean called canLoad in my script. I set it to true in the code and in the inspector it’s unchecked. I use it in the Menu_SP() method and when I start the game, it behaves how it should if it were false but it’s set to true. Why is this?

public class menuManager : MonoBehaviour {

	public string currentMenu;

	public bool canLoad = true;

	public GUIStyle menuBG;
	public GUIStyle Labels;
	public GUIStyle Buttons;
	public GUIStyle smallButtons;
	public GUIStyle notYetBttn;
	public GUIStyle Text;
	public GUIStyle smallText;

	void Start () {
		currentMenu = "Main";
	}
	
	void Update () {
		
	}

	void OnGUI() {
		if(currentMenu == "Main")
			Menu_Main();
		if(currentMenu == "SP")
			Menu_SP();
		if(currentMenu == "Opt")
			Menu_Opt();
	}

	public void NavigateTo(string nextmenu) {
		currentMenu = nextmenu;
	}

	public void Menu_Main() {
		GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "", menuBG);
		GUI.Label(new Rect(400, 50, 300, 50), "IDGAF", Labels);
		if(GUI.Button(new Rect(400, 150, 300, 50), "Singleplayer", Buttons)) {
			NavigateTo("SP");
		}
		if(GUI.Button(new Rect(400, 210, 300, 50), "Multiplayer", notYetBttn)) {

		}
		if(GUI.Button(new Rect(400, 270, 300, 50), "Options", notYetBttn)) {
			
		}
		if(GUI.Button(new Rect(400, 330, 300, 50), "Exit", Buttons)) {
			Application.Quit();
		}
	}

	public void Menu_SP() {
		GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "", menuBG);
		GUI.Label(new Rect(400, 50, 300, 50), "Singleplayer", Labels);
		if(GUI.Button(new Rect(400, 150, 300, 50), "New Game", Buttons)) {
			
		}
		if(canLoad == true){
			if(GUI.Button(new Rect(400, 210, 300, 50), "Load Game", Buttons)) {
			
			}
		}
		else if(canLoad == false) {
			if(GUI.Button(new Rect(400, 210, 300, 50), "Load Game", notYetBttn)) {

			}
		}
		if(GUI.Button(new Rect(400, 270, 300, 50), "Back", Buttons)) {
			NavigateTo("Main");
		}
	}

	public void Menu_Opt() {

	}
}

Because public variables only get their value from the script on the first time. You may have modified that variable from inspector and this value is now the chosen one. You can see that modifying the value in the script will not change it in the inspector.

The value in script is now “useless”.

You would have to click Reset in the top right drop down of the script. This would set the value to the one in the script.

Only private variables get their value from script.