Rivers
1
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 :
$Music.stop()
get_tree().change_scene_to_file(“res://Gameover.tscn”)
else:
pass
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:
$Music.stop()
Rivers
5
even after a null check music still equals null and nothing happens. The same scene continues playing and the music doesnt stop.
Rivers
6
I did a null check after the already set code but in the same fuction and it worked.
Thanks.
system
Closed
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.