Stuck with an error code message, on godot 3.5. 'Invalid set index 'value' (on base: 'Label') with value of type 'int'.'

Godot Version

3.5

Question

heya, i’m making a battle scene and typing in code that’s based on a rpg battle tutorial on youtube and have been struck with this error message.

Invalid set index ‘value’ (on base: ‘Label’) with value of type ‘int’.

at line 11, progress_bar value = health. the error jumps to 12 if i remove the value text on 11 and if i put line 12’s code on top i get “breakdown” as the error message instead. the og code didn’t use str() but the error remains the same before and after adding that in. Would anyone know what would be the issue with it?

extends Control


var current_player_health = 0

func _ready() -> void:
	set_health($gui/you/Panel/MarginContainer/VBoxContainer/PB/HP, State.current_health, State.current_health)
	current_player_health = State.current_health

func set_health(progress_bar, health, max_health):
	progress_bar.value = health
	progress_bar.max_value = max_health
	progress_bar.get_node("HP").text = "Health: %d/%d" % [str(health), str(max_health)]

Can you post a screenshot of your scene tree?

This node mentioned here is most likely of type Label, not ProgressBar, like you’d expect.

2 Likes

-_-, yeah that was it. PB is the progressbar and HB is the label. it’s working now and removed the str part of code so that the values are acknowledge by the code.

thanks