ScriptingProblems - Open door with 3 keys

Hi, I have a problem with my scripting. I’m doing a labyrinth game where you have to find 3 keys to open the final door to win the game.
I can collect the keys and it counts up in a guibox but I can’t open the final door and I have no idea why not. There are two scripts and a get the openfinaldoor var from the Keycollider script which is on my player. The Lockeddoorscript is obviously on my door.
Can anyone help me please :slight_smile: I would be so grateful.

LockedDoor.js

var openfinaldoor:Keycollider; 



// Smothly open a door
var smooth = 2.0;
var DoorOpenAngle = 90.0;
private var open : boolean;
private var enter : boolean;

private var defaultRot : Vector3;
private var openRot : Vector3;

function Start(){

defaultRot = transform.eulerAngles;
openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z);
}

//Main function
function Update (){



if(open){
//Open door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth);
}else{
//Close door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth);
}

if( openfinaldoor==true && Input.GetKeyDown("f") && enter){

open = !open;
}
}

function OnGUI(){

if(enter && openfinaldoor==true){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 300, 30), "You found the keys. Press 'F' to open the door.");}
else if (enter) {GUI.Label (new Rect(Screen.width/2 - 75, Screen.height - 100, 200, 30), "Find 3 keys to open the door.");}
}



//Activate the Main function when player is near the door
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}

//Deactivate the Main function when player is go away from door
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;
}
}

Keycollider.js

#pragma strict

import UnityEngine.UI;
import UnityEngine.GUI;


public static var keyCounter = 0;
public var customGuiStyle : GUIStyle; //Gestaltung der GUIBox
public var openfinaldoor : boolean; 
function Start () {
}

function Update () {

if (keyCounter ==3)
{openfinaldoor=true;}
else{
openfinaldoor =false;}
print(openfinaldoor);
}

function OnTriggerEnter(collision : Collider){

if (collision.tag=="Key"){
Destroy(collision.gameObject);
keyCounter = keyCounter + 1;
//Debug.Log("Bin drin");
}

}

function OnGUI(){

GUI.Box(new Rect (Screen.width/2-250,20,50,25), "" + keyCounter,customGuiStyle);

}

You can not compare a class with a bool. Replace this line:

if( openfinaldoor==true && Input.GetKeyDown("f") && enter){

with

if( Keycollider.keyCounter == 3 && Input.GetKeyDown("f") && enter){