Trying to check when a level was loaded

I have an audio loop that plays throughout the whole game. I want to destroy it when the Main Menu loads. (Or when the game is restarted.)

How can I check if a certain level was loaded so I can properly use Destroy(this)? Thanks!

Here’s a script I thought would work but its throwing an error:

function Update () {
	DontDestroyOnLoad(this);


if (Application.loadedLevel (0)) {
Destroy(this);
}

 	}

You’ll want to do that check in OnLevelWasLoaded, not in Update.

Ohh ok i see. Thanks man it worked out great :slight_smile: