Joining two booleans in different scripts

I have a small problem. I need to join two booleans in two differen scripts. Look:

First script

var havekey : boolean = false;

function OnTriggerStay (myTrigger : Collider) {
if(myTrigger.gameObject.name == “First Person Controller”){
Debug.Log(“Wanna take the key?”);

if (Input.GetButtonDown (“E”)) {
Debug.Log(“You picked key”);
havekey = true;

Destroy(gameObject.Find(“key”), 3);
}
}

}

Second script

var havekey : boolean;

function OnTriggerStay (myTrigger : Collider) {
if(myTrigger.gameObject.name == “First Person Controller”){
Debug.Log(“Wanna open door?”);

if (Input.GetButtonDown (“E”)) {
Debug.Log(“You re trying to open the door”);

if (havekey == true){
Debug.Log(“You had opend the door”);
gameObject.Find(“door”).animation.Play(“openingdoors”);
}

if (havekey == false){
Debug.Log(“Dont have the key”);

}
}
}
}

So this is it. I have no errors. I just need something like : if first script boolean = true than second script bollean = true and if first script boolean = false then second script bollean = false.

Thank you for help :expressionless:

That’s code duplication though. Sounds like you just want to reference the other script’s boolean.

if ( firstObject.GetComponent( FirstScript ).havekey )

I dont understand where I need to place it :frowning: sorry but I started with scripting maybie 3 days ago :frowning:

Before you start trying to write games you need to learn the basics of scripting. This is a good start:

http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)