void PauseButton() { menu.SetActive(!menu.activeSelf); for (int i = 0; i < players.Count; i++) { players[i].setInMenu(!players[i].isInMenu()); } Time.timeScale = (Time.timeScale == 0) ? 1 : 0; AudioSource[] audioSources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[]; foreach (AudioSource AS in audioSources) { if (AS.isPlaying) { AS.Pause(); } else { AS.UnPause(); } } }