#Cannot access Label in script

17 messages · Page 1 of 1 (latest)

wide pollen
#

Okay I'm sorry if this is a dumb question but I'm new to godot so I still don't understand everything :D
I have a script attached to a VBoxContainer and inside this container i have a Label: "fingerCounterLabel".
The problem is when I try to access the Label in the script I get the error that the Label is a null instance, so that the script can't acces the label.
And yes I have checked if the Label name is written correctly and I have checked if the label really is inside the VBoxContainer but I still can't get it to work

last mortar
#

When do you call the function?

wide pollen
#

when i press a button which is in another script

last mortar
#

try getting the label with @onready var finger_counter = $fingerCounterLabel on top of your script and see if that works. Have you checked the remote tree on runtime?

wide pollen
#

Sadly this still does not work
and do you mean that i should check if the label exists on runtime?

last mortar
#

yes.

wide pollen
#

idk if thats correct but when i look into the remote tree while running the script i can see the label

last mortar
#

Are you sure your code is in the correct script? Or maybe there is something funky going on with your other scripts

wide pollen
#

yeah the code is in the correct script but i can see if i can arrange the scene a bit differently and check if that works

last mortar
#

Can you also send the whole scene tree?

wide pollen
#

and another side question if i just want to group different nodes together what node should i use for that cus i used the canvasGroup but i dont think that thats correct

last mortar
#

try right clicking on the label and setting it to unique name (%)

#

Then use %fingerCounterLabel to access it

last mortar
wide pollen
last mortar
#

No this def should work. I think there is something going on with your scene!