play music throughout the game

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

I need music for my game, which i already have, but i don’t know how to implement it so it plays constantly throughout the game, even when switching scenes. does anyone know how to do this?

:bust_in_silhouette: Reply From: njamster

As you play your music with a node (of type AudioStream), the position of that node inside the scene tree matters. If it is a child of the current scene and you switch that scene out, you’ll also switch out the node that plays the music and it will stop playing. So the solution is simple: add the node somewhere else, e.g. as a Singleton.