private bool gameOver = false; //a local flag to prevent gameover routine being run twice public static void GameOver(bool won) //static function to end the game { if (!instance.gameObject.activeInHierarchy) { return; } instance.StartCoroutine(instance._GameOver(won)); }