0 votes

At the very end of this section of the tutorial:
https://docs.godotengine.org/en/stable/getting_started/step_by_step/ui_code_a_life_bar.html#update-health-with-a-signal-when-the-player-takes-a-hit

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 Player.gd 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.

Godot version 3.3.2stable.official
in Engine by (17 points)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.