Player health system won't subtract health

Hi I’m pretty new to coding and I’m trying to get the player’s health to subtract 10 points when I right click and for it to display onscreen, this is my code so far

var maxHealth = 100;
 public static var currentHealth = 100;
 var PlayerHealthDisplay : GUIText;
 
 function Start() {
     DisplayAmount();
 }
 
 function DisplayAmount () {
     PlayerHealthDisplay.text = ""+ currentHealth;
 }
 
function Update() {
 if(Input.GetMouseButtonDown(1)){

         currentHealth += -10;
      }
      }

It displays the 100 health onscreen, however when I right click nothing happens. Does anyone know what’s wrong?

You need to update the text of your GUIText object each time you change the value. Change Update() to:

function Update() {
    if(Input.GetMouseButtonDown(1)){
        currentHealth += -10;
        PlayerHealthDisplay.text = ""+ currentHealth;
    }
}