set_text group button nodes

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

Hi all,
I am using Godot 3.1
I have 21 buttons name:
btn1, btn2, btn3, … , btn21

Now I want to get this btn nodepath.
var i = 1
while(i<=21):
get_node(“ABC/XYZ/btn%d”%i).set_text(“X”)

but it’s not working. The ERROR is:
Attempt to call function ‘set_text’ in base ‘null instance’ on a null instance.

Anybody know how to fix it?

:bust_in_silhouette: Reply From: Nuwanda

if you want to set text to buttons then you can

for i in range(21):
get_node(“btn” + str(i)).set_text(“X”) # add underscore bw get node and set text