How to change the value in a texture progress bar

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

This is function that I was using to test damage in my game where if an enemy enters the area of the player to take 10 damage off of their total health and update the texture pregress node called HealthBar
export var health: = 100

func _set_health(value):
if health == 0:
kill()
else:
health -= 10
get_node(“HealthBar”).set_value = health

Whenever I run the code it has an error that says "invalid set index ‘set_value’ (on base: ‘control’) with value of type ‘int’
Can someone please help me fix it
Thanks

:bust_in_silhouette: Reply From: kidscancode

The property is called value not set_value:

get_node("HealthBar").value = health

When I run it with the:
func _set_health(value):
if health == 0:
kill()
else:
health -= 10
get_node(“HealthBar”).value = health
it still comes up with the error "invalid set index ‘value’ (on base: ‘control’ with value of type ‘int’

ChiCHOKEme | 2019-11-06 03:04

It seems that “HealthBar” is a Control node, but not a TextureProgress. Therefore it doesn’t have a value property.

kidscancode | 2019-11-06 03:08

Nevermind I fixed it, the problem seemed to be that it was a separate scene that I put in the player scene and then it refused to work but now I tried putting the texture progress directly in with the player scene and all works perfectly

ChiCHOKEme | 2019-11-06 03:15

thanks, i also did what you did, and it solve the problem bro.

morningkingdom | 2021-02-01 19:16