Door Opens When Not In Trigger And Sound Help

I made a door and scripted it so whenever I hit “e” it opens or closes, however whenever i hit “e” it opens or closes regardless of where i am in the map. only when i step in the trigger at least once does it make it so i cant.

This is the script for the door;
// Smothly open a door
var smooth = 2.0;
var DoorOpenAngle = 90.0;
var DoorCloseAngle = 0.0;
var open : boolean;
var enter : boolean;

//Main function
function Update (){

if(open == true){
var target = Quaternion.Euler (0, DoorOpenAngle, 0);
// Dampen towards the target rotation
transform.localRotation = Quaternion.Slerp(transform.localRotation, target,
Time.deltaTime * smooth);
}

if(open == false){
var target1 = Quaternion.Euler (0, DoorCloseAngle, 0);
// Dampen towards the target rotation
transform.localRotation = Quaternion.Slerp(transform.localRotation, target1,
Time.deltaTime * smooth);
}

if(enter == true){
if(Input.GetKeyDown("e")){
open = !open;
}
}
}

//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;
}
}
//@youtube.com/user/maksimum654321

I am also wondering what to do to make a sound play whenever the door opens or closes as well.

you have the bool enter.

It appears that determines whether your allowed to open the door right?

but when you declare a bool its default value is true;

so

bool enter;

if (enter)
{
   will happen cause its true by default
}

the answer is to go to where you declare true or the function OnStart() and set enter to false.