3.2 to 4.2.1 stat system for game

Godot Version

gdscript game 2d godot-4 Help


for button in get_tree().get_nodes_in_group(“plusbutton”):
button.connect(“pressed”, self, increase(), [button.get_parent().get_parent().get_name()])

func increase(stat):
set(stat.to_lower() + “_add”, get(stat.to_lower() + “_add” ) + 1)
get_node(path_main_stats + stat + “/Background/Stats/change”).set_text(“+” + str(get(stat.to_lower() + “_add”)) + " ")

the code just doesn’t convert from 3.2 to 4.2.1, the .connect doesn’t support the amount of things in it, i added a var to incorporate the get name but that didn’t work and the label change is coming back as null instance what do i do and is there any code you can send me to substitute for this

The syntax for connecting a signal in godot-4 is:


Cleaner version

var button_parent_name: String = button.get_parent().get_parent().get_name()

thank you so much, that solved one issue i was having. Now i need to figure out why its calling a null instance for the label that its affecting.

1 Like