public void DoPause() { //Set isPaused to true isPaused = true; //Set time.timescale to 0, this will cause animations and physics to stop updating Debug.Log("Pausing Time 2"); Time.timeScale = 0; //call the ShowPausePanel function of the ShowPanels script int timeElapsed = (int)GameObject.Find("Game_Logic").GetComponent <GameSystemController>().timeElapsed; showPanels.ShowGameOver(); Text text = (Text)GameObject.Find("TimeText").GetComponent <Text>(); text.text = "Time: " + (int)timeElapsed; }