Get valor of variable in another script

Hi, I have two scripts,
health.js

var health = 100f;
var enemy : GameObject;
    
        
    function OnTriggerEnter (bullet : Collider)
    {
    	 Debug.Log(health);
    
    
         if (bullet.gameObject.CompareTag("bullets")){
    
    
           vida -=1;
           Destroy(Bala.gameObject);	
    	   if (vida <=0)
    	   {
    	     	Destroy(Enemigo,0f);
    	   }
         }
    }

and hpbar.js for health bar.

var target : Transform; 

 
function Update () 
{
	
    var wantedPos = Camera.main.WorldToViewportPoint (target.position); 

    transform.position = wantedPos; 

}

And I need valor of health variable in health.js on hpbar.js for decrease the health bar.
Help pls! :slight_smile:

the health variable needs to be static but you won’t see it anymore in the inspector:

static var health : float = 100;

Your script name is “health” and the variable name is health too, which is a bad thing, rename the script to something else, like “Player.js” or whatever, then acces the variable like this:

someVar = Player.health;