I am trying to make a health bar and have it so once i click a object the numbers and bar itself go down. however this isnt working and i dont know what the problem might be.
{
public Text p_health_Text;
public Slider p_health_bar_slider;
public float p_current_health;
public float p_max_health;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
p_current_health = p_health_bar_slider.value;
p_health_Text.text = "" + p_current_health;
}
public void ChangeHealth(float amount)
{
p_health_bar_slider.value = p_current_health / p_max_health;
}
}