Cannot tween audiostreamplayers in autoload scene

Godot Version



I created an autoload scene to handle the music for my game. In it, there’s a function for fading in and out music by tweening the volume of the AudioStreamPlayers. For some reason, when using this function, this completely breaks all sound in the game until the tween is done. The other two functions work completely fine.

I know it’s not an issue with how I used the tween, since I tested the function outside of an autoloaded scene and it worked fine. Unfortunately, I need it in the autoloaded scene to work with the rest of my game’s logic.

So far, I haven’t found anyone who’s run into a similar issue. Any help would be greatly appreciated. Thank you.

extends Node
@onready var game_music = $GameMusic
@onready var sunrise_music = $SunriseMusic
@onready var menu_music = $MenuMusic
@onready var shoot_the_saucers_music = $EasterEggMusic

func play_music(music:AudioStreamPlayer, play:bool=true, volume:float=1)->void:
	if play:
		music.volume_db = linear_to_db(volume)

func set_volume(music:AudioStreamPlayer, volume:float):
	music.volume_db = linear_to_db(volume)

func smooth_fade(music:AudioStreamPlayer, final_vol:float, time:float):
	var tween = create_tween()
	tween.tween_property(music, "volume_db", linear_to_db(final_vol), time)

@export var bgm_player: AudioStreamPlayer2D
var tw_fading_bgm:Tween

func update_bgm_player_volume(value: float):
	bgm_player.volume_db = linear_to_db(value)

func fade_out_bgm():
	tw_fading_bgm.tween_method(update_bgm_player_volume, bgm_volume, 0.0, .25)

func fade_in_bgm():
	tw_fading_bgm =create_tween().bind_node(bgm_player)
	tw_fading_bgm.tween_method(update_bgm_player_volume, 0.0, bgm_volume, .25)

example of fade in or out bgm, can be called by signal