Weird code problem thats probably really simple

Godot Version



In this image, a timer happens that causes a crowd sound, and you have 5 seconds to press a button. But the button just doesn’t seem to be clickable. Another problem is I have the audio stream player stop when the 5 seconds of not clicking the button finishes, but the audiostreamplayer doesn’t stop when the 5 seconds finish. I don’t know whats causing this.

your _init() first line isnt right, looks like you are using connect of godot 3, not godot 4’s signal connect
it should be looking like this:


the ButtonClicked should be a function in this script

That didn’t seem to change anything. I still can’t click the button, and the audiostream player glitch is still happening too. The button clicking not working isnt showing up as a glitch though.

at the top of your code write

@onready var audio = get_parent().get_node("AudioStreamPlayer")

and use audio when referencing your $AudioStreamPlayer eg replace $Game/AudioStreamPlayer.stop() with audio.stop() because your problem is the fact that your node is below the root node so get_parent() selects the node above your current node @Qwergin

As an aside, you should be doing that connection in the _ready() function not in the _init() function.
There are a couple of pitfalls you can stumble into overriding the _init() function.
_init() is a class constructor and if you are not instantiating class instances in code then there is no reason to override _init().

if you want easy fix, it should be just

change the