Health Bar problem

I need help with a health bar that displays a colour and the word health and decreases by 10 when hit by rigid body’s and when the number gets to zero it freezes the game and says game over restarts please help everything i try fails.
The script i have so far is

var healthbar
//if healthbar is 100 and is hit by collider decrese by 10
FunctionOnCollision : 100,0
    if Collision decrease by 10 and if hit 0 Destroy "FPSPlayer"
}

something like this ? p.s. might not be perfect, I use c# but right idea i think…

    var health: int = 100;
    
    function OnCollisionEnter(collision : Collision){
    
    if(collision.gameobject.name == "//name of thing"){
    
    var health -= 10;
    
    }
    
    }

    function Update(){

        if(health <= 0 ){


         Deastroy(//whatever variable as long as it is an instantiation);

         }

    }