Score / Loading Level

I have a level that requires 10 points to win. Right now, I can get 10 points, but the next level does not load. Can anyone tell me how to script a level to load upon completion of the score reaching 10? All help is greatly appreciated. Thank you!

Shawn


Updated with Shawns code in comment reply:

I am lost, here is my code:

var score = 0; 

function Update()
{ 
    if (score > 4)
    { 
        Application.LoadLevel(1); 
    } 
} 

And this is my score script:

var cam : GameObject; 
var Win : GameObject; 
var Lose : GameObject; 
var score = 1; 

function AddToScore() 
{ 
    ++score; 
    guiText.text = "Score: " + score.ToString();
} 

function SubtractFromScore()
{ 
    --score; 
    guiText.text = "Score: " + score.ToString();
} 

~Statement


You can do something like this if your levels are next to each other by index:

// if score is 10 or more
if (score >= 10)
{
     // if we aren't at the last level
    if (Application.loadedLevel != lastLevel)
    {
        // then load the next level
        Application.LoadLevel(Application.loadedLevel + 1);
    }
    else
    {
        // Game completed!
    }
}

I am far from an expert. I am new to programming and still trying to figure out how to get my scores to carry over. But i found a cheating quick fix. this will do till you find a better way.

function Update () {

if(playerScore ==2000){

Application.LoadLevel(3);

playerScore = 2001;

}

if(playerScore ==4001){

print("Level 2 complete");

Application.LoadLevel(4);

playerScore = 4002;

}

if(playerScore == 6002){

print("Level 3 complete");

Application.LoadLevel(5);

playerScore = 6003;

}

if(playerScore == 8003){

print("Level 4 complete");

Application.LoadLevel(6);

playerScore = 8004;

}

if(playerScore == 10004){

print("Level 5 complete");

Application.LoadLevel(7);

playerScore = 0;

}

if(playerLives <= 0){

Application.LoadLevel(8);

playerScore = 0;

}

}

function OnGUI(){

GUI.Label(Rect(10,10,200,50), "Score: " + playerScore);

GUI.Label(Rect(10,30,200,50), "Lives: "  + playerLives);

}

just adjust the scores to your own levels... and change the load level to what yours are.