Problem with "if all conditions are met, open the door" type of script

Hey, I'm having a problem with a script that I'm working on. Here's what I have so far (special thanks to Duck for helping with this earlier):

private static var numRemainingClues = 0;
private var shown = false;
var noteText : String = "";
//var other : GameObject;
var door:GameObject = GameObject.Find("DoorOpen") ;

function Start() { 
    //each clue counts itself when it starts:
    numRemainingClues++;
}

function OnGUI() {
    GUILayout.BeginArea (Rect((Screen.width/2)-50, (Screen.height/2) , 300, 300));
    GUILayout.Label(noteText); 
    GUILayout.EndArea ();
}

function OnTriggerEnter( other : Collider ){
    noteText = "Insert Clue Text Here";
    // each clue counts itself out when shown for the first time:
    if (!shown) {
        shown = true;
        numRemainingClues --;
        if (numRemainingClues == 0) {
            door.animation.Play("DoorOpen"); // however you want to trigger that
        }
    }
}

function OnTriggerExit( other : Collider ){
    noteText = "";
}

The problem is that when I walk into ANY clue (each clue has a collider around it with the above script attached), the door opens. I need to make it so only after you've walked into all FIVE of the clues, the door will open. Thanks!

There must be something wrong with the way that you have the clue objects set up in your scene, because that code works exactly as intended.

I tried a version which confirms this by deactivating the lines relating to the 'door' obkect, and adding some Debug.Log lines, which may help you to identify your problem.

Check that when you start your game, the number of clues present is counted up in the console. Then check whether the number remaining is decreased correctly each time you touch one of the remaining clues:

private static var numRemainingClues = 0;
private var shown = false;
var noteText : String = "";

//var door:GameObject = GameObject.Find("DoorOpen") ;

function Start() { 
    //each clue counts itself when it starts:
    numRemainingClues++;
    Debug.Log("Registered clue number "+numRemainingClue);
}

function OnGUI() {
    GUILayout.BeginArea (Rect((Screen.width/2)-50, (Screen.height/2) , 300, 300));
    GUILayout.Label(noteText); 
    GUILayout.EndArea ();
}

function OnTriggerEnter( other : Collider ){
    noteText = "Insert Clue Text Here";
    // each clue counts itself out when shown for the first time:
    if (!shown) {
        shown = true;
        numRemainingClues --;
        Debug.Log("Num Remaining Clues: "+numRemainingClues);
        if (numRemainingClues == 0) {
            // door.animation.Play("DoorOpen"); 
            Debug.Log("Touched All Triggers!");
        }
    }
}

function OnTriggerExit( other : Collider ){
    noteText = "";
}

I am pretty new to Unity myself, and am not 100% sure how the static variables work, but just a guess would be to remove private from your static variable. It looks to me like it is incrementing the count to 1, then decrementing it back to 0 when the trigger is entered.

Like I said, I am new to this myself, and could be completely wrong here :)

-Larry