image.fillamount doesnt decrease

hi, i’m using the fill amount to change the health bar state, the value of decreasing depends on the weapon, i store the damage value in a variable called “value” and from another script i do this :

public void SetValue(float value)
    {
        maskblue.fillAmount -= value;
    }

the fill amount doesn’t change and stay 1, but if i change " value" by a float number ( 1f, 0.5f ) it works !
notice that in the other script i call the previous function “SetValue” like this :

 public void ChangeHealth( float amount )
    {
        currentHealth += amount;
        HealthBar.instance.SetValue(amount);
    }

where the value of " amount" depends on the weapon’s bullet ( -0.1 , -0.2 …) i only did the -0.1 for no so…
I hope someone can help me! thank you.

How are you referencing this health bar script in the weapon script? It doesn’t look like the SetValue() function is getting the (float value) amount from that weapon script if it works when you manually enter the value.


An example would look something like this

public class Damage : Monobehaviour
{
HealthBarClass healthBar;

public void Start()
{
healthBar = GameObject.FindObjectOfType<HealthBarClass>();
}

public void Damage()
{
damage = weapon.Damage;
healthBar.SetValue(damage);
}
}