I’m attempting to stop the playing music when a level is over, so I can then play a little victory sound effect. When I try to stop the sound before I play the victory sound, I get either an Accessed None or Attempted to Read Property error, seemingly interchangeably. (Sometimes I get one and other times I get two errors) Running the code this way does exactly what I want the game to do in play mode, but it throws this error. I previously had the Stop Sound node at the end of this line of code and it does not throw these errors there. I’m not sure why, since no value is assigned to Music (my problem component) between the beginning and end.
What am I doing wrong here?
If you get that error, it means that your music reference is not set. You just have to trace back and see where that is.
The only place I see you setting it at all is in the MusicSystem custom event, which doesn’t cope for the case when level is not 1 or 2. Could it be that?
First, I must say its an honor to get an answer from the Legendary ClockworkOcean. I hope you top the Karma leaderboard, once again.
How would I set a play sound variable before I play a sound? I can’t seem to add a default value or anything.
You are setting the sound ref, at least at some point:
But, maybe you code is going down here:
or maybe the sound has stopped playing? I’m not sure.
You can always avoid the problem with
Thanks! Is Valid into a Stop worked. I’ll always be playing a sound with Music when that Custom Event is executed anyway. Neat little trick to avoid errors.