Help me to make global music in project PLZ

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SDW

If you can…Plz help me to make global music in all scenes

Now I have

extends Control

# Load the music player node
onready var _player = $AudioStreamPlayer

# Calling this function will load the given track, and play it
func play(track_url : String):
    var track = load(track_url) = track

# Calling this function will stop the music
func stop():

But code shows me

Invalid set index ‘stream’ (on base: ‘null instance’) with value of type ‘AudioStreamOGGVorbis’

On other scene I summon my PLAY function"res://SFX/zvuki-signal-trevogi.ogg")

From the looks of it, the variable _player in the _play() function is null. In that “other scene”, it may have a $AudioStreamPlayer, while the original scene does not.

Ertain | 2019-12-12 07:21