0 votes

I have no clue why this keeps happening as I'm using the exact function I've used in other projects.

func _on_Button_pressed(button):
 button.disabled = true

func update_row_state(button):
    var buttons = get_tree().get_nodes_in_group(button.type)
    for button in buttons:
        if button != button and button.pressed:
            button.pressed = false

I know for a fact the buttons are in the group, and I know it's looking for the right group, it just keeps giving me the error "Attempt to call function 'getnodesin_group' in base 'null instance' on a null instance"

in Engine by (206 points)

1 Answer

+1 vote
Best answer

It's get_tree() that returns a null instance. It means your node is not in a SceneTree when get_nodes_in_group() gets called.

You can check if a node is in a SceneTree with is_inside_tree().

by (2,298 points)
selected by

Yep this is correct. I connected the onButton_pressed signal within the button node itself by instancing the main scene which led to a bunch of funky logic.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.