Adding varibales from other scripts

I have three scripts:

Variable:

static var score = 0;

Present 1:

var score= Variables.score;

function OnTriggerEnter ()
{
score = score+1;
}

and win:

var score= Variables.score;

function Update(){
if(score==1){
Application.LoadLevel("Level 1");
}
}

I want it to go to the next level once var score equals 1 (for now). It isnt working and im not sure why because it not giving me any errors. Please help.

A few questions. these are all in different scripts? Why not just put

function OnTriggerEnter ()
{
    Application.LoadLevel("Level 1");
}

unless you plan on adding more “score” points to later levels.
is score used anywhere else? i see its static, maybe another object is setting it back to 0 before it get to the update loop.

you could also remove the update function and put the if statement inside the function onTriggerEnter after increasing the value of score variable and yes, your code might work but it is just not simplified.

How i understood it’s a different scripts ?

First is :

var score= Variables.score;
 
function OnTriggerEnter (){
 score = score+1;
}

and second is :

var score= Variables.score;
 
function Update(){
 if(score==1){
  Application.LoadLevel("Level 1");
 }
}

if so, that will not work, because in first script you load your ‘Variables.score’ into local variable ‘score’ and raise it, but in second script you again load your ‘Variables.score’ which wasn’t changed and still equals 0.

To fix it you must change your first script like that:

function OnTriggerEnter (){
 Variables.score = Variables.score+1;
}

or

function OnTriggerEnter (){
 Variables.score++;
}