Need help accessing a variable in another script

My first script is like this

function Update () {
var hp = 100;
var r : float;

var color : Color = Color.white;
color.r = 0;

if (hp < 20)
	{
	camera.backgroundColor = color.white;
	}

}

second script:

var hp : Health;
function Update ()
{
   Health.hp = 1;
}

I’m trying to set the hp equal to 1 from the first script but I get the error: "Assets/Scripts/Point Hurt.js(4,11): BCE0019: ‘hp’ is not a member of ‘Health’. "

What am I doing wrong?

hp = 1; tell me if it works.

You need to get a reference to the other script. http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

–Eric

No that didn’t work but I figured it out. I had to set the variable hp to static :slight_smile:

static var hp = 100;
var r : float;
function Update () {

var color : Color = Color.white;
color.r = 0;

if (hp < 20)
	{
	camera.backgroundColor = color.white;
	}

}