How do i use a value from a var

Hello,
I am having trouble getting a object to spawn in once i hit a certain value, This is what i am trying to do…

var rank = 0;


function Update () {

    if (rank == 5){
        Debug.Log("We unlocked first item");
    }
}

I replaced everything with a Debug to see if its working But it dose not seem to work out when i change the value to 5, Any help would be greatly appreciated.
Thanks.

Perhaps you could try something like this instead:

#pragma strict

private var rank : int = 0;

function Start () {
	InvokeRepeating("RankUp",1,1); //For testing purposes, use RankUp() when condition for ranking up is met
}

function RankUp () {
	rank++;
	switch (rank) {
		case 1: Debug.Log("Rank is now "+rank); /*Give special values for rank 1*/ break;
		case 2: Debug.Log("Rank is now "+rank); /*Give special values for rank 2*/ break;
		case 3: Debug.Log("Rank is now "+rank); /*Give special values for rank 3*/ break;
		case 4: Debug.Log("Rank is now "+rank); /*Give special values for rank 4*/ break;
		case 5: Debug.Log("Rank is now "+rank); /*Give special values for rank 5*/ break;
		default: Debug.Log("Rank is now "+rank+" which is over the rank limit"); break;
	}
}

The problem you had is most likely because Unity has serialized the value for rank and put it in the Inspector, changing the value inside the script wont make any difference. Remember to type all your variables (var rank : int = 0).