Problem with tutorial "Control the game's UI with code"

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

At the very end of this section of the tutorial:

There’s this part:

func update_health(new_value):
number_label.text = str(new_value)
bar.value = new_value

When trying to run the game with F5 as it says, it doesn’t work and the debugger says “Invalid set index ‘value’ (on base: ‘TextureProgress’) with value of type ‘String’.” I tried changing bar.value = new_value to bar.value = int(new_value) and it then worked, though I have no idea why. I’m looking at the script and it’s pretty clear that the health variable being emitted is an integer, not a string.

Just thought I would mention this for whoever maintains the tutorial webpages, this stumped me for at least an hour and I still don’t know why it didn’t work.

It would be better to post this on the documentation github instead of here.

exuin | 2021-05-29 06:57