Hi everyone, I have a problem and Im struggling in finding the solution. I have to update a text label from a script, the text label is located in another node the Canvas "HUD/Coins"

Have a look at the code below, this line is wrong: get_tree().get_root().get_node("MainScene2D").get_node("HUD").coins.text = String(player_data.coins)

any help please?

Welcome to the forums @"K-Storm-Studio Ltd"!

If you change line 54 to the following, I believe it will work (untested):

get_tree().get_root().get_node("MainScene2D").get_node("HUD/Coins").text = str(player_data.coins)

The issue with the original code is that you are trying to access a child node using a property get_node("HUD").coins rather than getting the child node from the HUD node: get_node("HUD/Coins") or get_node("HUD").get_node("Coins").

Twisted, thank you so much! It does work :)

I'm trying with other variables now :)

Been looking for this for a long time. Thank you!

2 years later