get_node("../..")
<-- goes up to levels in the hirarchy
$Label
<-- accesses a child node called "Label"
getnode("../Label")
<-- goes up one level in the hirarchy and accesses a child from that level
called "Label"
So, do this: get_node(nodepath).set_text(score)
That said, a better way would be to connect the Area2D's
signal to the Label node
. To do that, click on your Area2D node
once, change from the Inspector
tab to the Node
tab. Double click on the signal called "body_entered"
. A window pops up, where you can double click on a node
in the hirarchy
, which will create a function
in that node
, which will be called everytime a body enters the Area2D
.
When on the script tab in godot, you can click "Search Help" and search the documentation for such things. Works like a charm.