public void TogglePause() { //if not in the main menu, the proceed with togglepause if (SceneManager.GetActiveScene().name != "MainMenu") { //check the bool if (isPaused == false) { sfx.PlayPause(0); //0 = Pause sound isPaused = true; //flip the bool pausedTimeScale = Time.timeScale; //capture current timescale Time.timeScale = 0; //set timescale to 0 } else { sfx.PlayPause(1); //1 = unpause sound isPaused = false; //flip the bool Time.timeScale = pausedTimeScale; //set the timescale to what it was before } } }