0 votes

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)
    _player.stream = 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

in Engine by (14 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.