IInvalid set index 'volume_db' (on base: 'null instance') with value of type 'int'.

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

I get the error “Invalid set index ‘volume_db’ (on base: ‘null instance’) with value of type ‘int’.”

Quiz.gd:15 @ _ready(): Node not found: “AudioStreamPlayer” (relative to “/root”). Also this error, here is the line thats giving me a problem

get_parent().get_node("AudioStreamPlayer").volume_db = -20
:bust_in_silhouette: Reply From: jgodfrey

This part of the above code is failing…


That’s saying that, starting from the node that’s associated with the above script, get it’s parent, and then get a child of that parent named AudioStreamPlayer. So, effectively, that means that the AudioStreamPlayer node you’re trying to access would be a siblling of the node running the above script. That’s apparently not the case, so the result is null.

If that doesn’t help you solve the problem, we’ll need to know how your scene tree is organized, and which node has the above script.

when I remove the volume-db = -20 it works

givenmnisi6 | 2023-06-10 19:11

Yeah, it would. The result of the get_node() call is null. There’s nothing technically “wrong” with that until you use it to try and reference something associated with the expected object. In this case, that’s the volume_db property.

So, again, that get_node() call is failing because your scene tree isn’t organized in a way that matches your code.

jgodfrey | 2023-06-10 19:15

Oh I see, thank you so much.

givenmnisi6 | 2023-06-10 20:12