0 votes

im trying to make a hp bar with textureprogress (for a rpg game), but in the script, when i try to change the "value" and "max_value" irecive this error: Invalid get index "maxvalue" (on base "texturepogress") with value of typi "Nil".
so I think I can solve it by changing the type of the variable, but i dont know how.

onready var vida_bar = $evilbar #textureprogress
onready var malovida = $evillife

var life
signal win

func _ready():

func _on_grid_atack(damage):
    life = life - damage
    evillife.text = String(life)
    if life <= 0:

func _on_grid_hpevil(hp):
    life = hp
    life_bar.value = hp
    life_bar.max_value = hp

func update_hpbar():
    vida_bar.value = vidamalo
Godot version 3.4.2
in Engine by (23 points)

1 Answer

+1 vote
Best answer

I don't know the texture progress functions but in your code I see that you are using a declared but undefined variable: life.
Give that variable a value when declaring it e.g. life=100 and call _on_grid_hpevil() function with some value e.g. _on_grid_hpevil(100)

by (2,252 points)
selected by

thanks, now it works correctly

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.