"Invalid set index" error when attempting to call global var to a label

Godot Version



I have created the line to edit a label’s text with a global variable max_health, but when attempting to run this script I end up with the error “Invalid set index ‘text’ (on base: ’ Label’) with value of type ‘int’”. I have been attempting to get this to work for close to two hours now lol

extends VBoxContainer

# Called when the node enters the scene tree for the first time.
func _ready():
	$HPPoints/HPInfo.text = global.max_health

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):

GDScript doesn’t auto-cast number to strings. Try to use str(global.max_health) instead.

1 Like

Worked, thank you very much!