"Invalid assignment of property or key 'text'"

Godot Version

v4.6.3

Question

So Im attempting to display the value of a variable (that I have already made global in my project) on this label node. But I keep getting the same error of, "Invalid assignment of property or key 'text' with value of type 'String' on a base object of type 'null instance'".

Here is my code:

Dont mind the naming, but “Guh.guh_amount” is my global variable that I want to display the value of

Can you share a screenshot of the node tree where this script is attached to?

Yes the script is attached to the wallet node

It should be text as the this is the node itself, otherwise you’d be trying to access a child of that

If it’s attached to the Wallet node, then you don’t need the $Wallet part in your script. Just do text = ...

oh gotcha! thank you!

So i did this, but the text itself wont change within the game, I checked to make sure the guh_amount was changing by printing out its value every time i click it, and it is working.

Try this:

extends Label


func _process(_delta: float) -> void:
	print("Guh Amount: %s" % Guh.guh_amount)
	text = str(Guh.guh_amount)