The problem is that when I create a label (stored in a separate scene that I create) and change the text from the default I have set, the string “Nothing” to “H”, it works, but if I try and do it a second time the label has no text.
what is the code that you use to change the text of the label?
You have stored the label in a separate scene? This means you have a reference to the label scene, right?
In that case labelscene.text = "Test", assuming your Label is the root node of your scene.
If you set the text in your _ready() method, then it is only called once.
okay. Based on this, I know that your label variable is gone once the method ends.
Can I ask you to create a local label variable inside your script?
var label: Label
func wherever_this_is() -> void
var LABEL = load(“res://Prefabs/label.tscn”)
label = LABEL.instantiate()
ROOTNODE.add_child(label)
label.text = newtext
label.set_z_index(100)
once this method ends, you still have a reference to your label. You can then do label.text = "XXX" outside of the method (as long as the label actually exists in the SceneTree).
I also assume that your label position is set correctly when you add the label child into your ROOTNODE, because you wrote that you can see the text changing the first time.
for the moment that would work fine but I would encourage you to create a system so the setting of the label text only works when you need it.
The _process() method runs once per frame so the text is repeatedly set which could lead to performance issues