как исправить ошибку: Invalid set index 'text' (on base: 'null instance') with value of type 'String'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CherkAD

пожалуйста помогите исправить ошибку: Invalid set index ‘text’ (on base: ‘null instance’) with value of type ‘String’.

extends TextureRect

func set_item(item_name, amount):
texture = load(“res://текстуры/item/%s.png” % item_name)
$Amount.text = str(amount) <—ошибка здесь

:bust_in_silhouette: Reply From: godot_dev_

The error indicates that the $Amount.text = str(amount) line of code is the source of the bug. Your $Amount node is null, and therefore you cannot set a string to its member text. Make sure the node with your script has a child node named Amount and has the text member (for example, a Label), because the error your getting means you have no such child node