Hi, I’m attempting to make the buttons play a sound when hovered over. I have the button set up in it’s own scene, with an AudioStreamPlayer as a child. I’m adding the button different scenes, and the button does work, but I’m getting an error (Image at the bottom).
I would like to note that I have assigned a sound to the AudioStreamPlayer, but the sound is not playing.
show us inspector section when it’s selected in scene_tree
also I don’t see your stream_player instantiated so it’s quite logical it’s won’t find it , as well as @normalized mentioned the script it’s not attached to that node.
I’ll try to answer the best I can. I’m sorry if I didn’t understand.
I implement the Animated Button with the Add Child Node. I make the AnimatedButton a child of the GridContainer, which is a child of the MainMenu node.
I’m guessing the code is not Instating the AudioSteamPlayer.
@onready var button_hover_click: AudioStreamPlayer2D = $ButtonHoverClick
code is only searching at start to have ready variable button_hover_click linked to $ButtonHoverClick which doesn’t exist because is not instantiated .
Solution
save this as scene and instantiate this scene under a child of the GridContainer .