The complete error is:
NullReferenceException: Object reference not set to an instance of an object
MusicPlayer.OnLevelWasLoaded (Int32 level) (at Assets/Scripts/MusicPlayer.cs:53)
Occurs when you’re assigning a different audio clip to music.clip. Also occurs when music.Stop() is used. I’d downloaded the completed project to see if the errors occur and they still do.
I’ve went ahead and set up the audio sources differently without the use of the MusicPlayer script in order to avoid the NullReferenceException errors. Since every scene has their own background music and the music will only play on specific scenes, I added Audio Source components to the hierarchy of every scene, and you can easily use the options in the Inspector for looping and playing on wake.
It seems like it might have something to do with the scope of ‘music’.
private AudioSource music;