IEnumerator IsGameOver() { while (true) { //if the game is over, stop spawning obstacles, //create a list of everything that's moving left //and stop them from moving left if (playerControllerScript.isGameOver) { spawnManagerScript.StopCoroutine("SpawnObstacles"); StopCoroutine("ScoreCounter"); movingObjects = FindMovingObjects(); foreach (GameObject movingGO in movingObjects) { moveLeftScript = movingGO.GetComponent <MoveLeft>(); moveLeftScript.StopCoroutine("MoveMeLeft"); } finalScoreText.text = "updated"; restartButton.gameObject.SetActive(true); scoreText.gameObject.SetActive(false); finalScoreText.text = "Final Score: " + scoreStr; finalScoreText.gameObject.SetActive(true); yield break; } yield return(null); } }