Error

So I keep getting this error “Namespace cannot directly contain members such as fields or methods”. I’m not sure what’s wrong as I’m quite new.

using UnityEngine;
using UnityEngine.SceneManagment;

public class GameManager :
MonoBehavior
{
bool gameHasEnded = false;

public void EndGame ()
{

if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log(“GAME OVER”);
Invoke(“Restart”, 2f);
}
      }

}
public void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

Fix your indentation, and the problem will probably become apparent. Indent (once) after every opening {. Outdent (once) after every closing }. The last } should end up unindented at the end of the file.

Thanks!