Stop music playing after changing scenes.

I have a main menu that plays music and i click on a button that takes to me to a different scene, the music continues to play (Good) but when i go to the main game it continues to play (This is what i want to stop). I have tried many things and the one that i think should work doesn’t.

if (Application.loadedLevel == 0)

	{
		DontDestroyOnLoad(transform.gameObject);
	}
	else
		if (Application.loadedLevel == 2)
	{
		Destroy (gameObject);
	}

The script has the code to play the music and that’s why i have to don’t destroy on load, i thought that if i deleted the object the music would stop. I get no errors in the console it just doesn’t work.

Please try and help me.

Thank you for answers

You need to get rid of the else, if that doesn’t work make sure that you have the third scene in your build settings loaded.