Can't hear Audiostreamplayer2D

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

I got game and cions in it. So there are level1 scene and coin scene. In coin scene i use this:

extends Node2D

func _on_Area2D_body_entered(body):
if “Player” in

but when player “pick up” the coin, i don’t hear the sound of Audiostreamplayer2D. (i load the .ogg file in it, yes).
Any ideas?

:bust_in_silhouette: Reply From: p7f

You are freeing the resource with queue_free, so, the sound, if starter, will stop.

You could connect the finished signal of AudioStreamPlayer2D to a function that calls queue_free so you make sure the resource is alive enought to the audio to play.