Cant call stop on audio before changing scene. PLEASE HELP!

When I try to call stop() on looping audio before changing scenes I get this error.

Attempt to call function ‘stop’ in base ‘null instance’ on a null instance.

here is the code I am using.

func _process(delta):
if VLifescore <= 0 :

what am I doing wrong.

What type of node is $Music? It is an Audiostream node?

It seems that _process is called before $Music is initialized. You better add a null check.

if VLifescore <= 0 and $Music != null:

audiostreamplayer node

even after a null check music still equals null and nothing happens. The same scene continues playing and the music doesnt stop.

I did a null check after the already set code but in the same fuction and it worked.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.