If I use SetActive(false) on an object, can I not use SetActive(true) on it afterwards?

Here’s the code in question. Once I run SetActive(false) on pause it gives me a nullreferenceexception when I try to set it back to true.

if (Input.GetKeyDown (KeyCode.Escape) || Input.GetKeyDown (KeyCode.P))
		{
			if (Time.timeScale > 0)
			{
				GameObject pause = GameObject.Find ("paused");
				pause.SetActive(true);
				
				Time.timeScale = 0;
			} else {
				GameObject pause = GameObject.Find ("paused");
				pause.SetActive(false);
				
				Time.timeScale = 1;
			}
		}

The technical answer to your question is yes you can, but unfortunately, GameObject.Find will not see deactivated objects. If you want to be able to toggle it on and off at run time you will need to store it in a persistent variable, try making GameObject pause a class variable, and either setting it in the editor, or doing the GameObject.Find in your start function. Like this:

GameObject pause;

void Start()
{
    pause = GameObject.Find("paused");
}

void someFunc()
{
   if (Input.GetKeyDown (KeyCode.Escape) || Input.GetKeyDown (KeyCode.P))
   {
     if (Time.timeScale > 0)
     {
      pause.SetActive(true);

      Time.timeScale = 0;
     } else {
      pause.SetActive(false);

      Time.timeScale = 1;
     }
   }
}