problem declaring an array inside an if statement

I’m running into a few problems with an advanced door script which checks the current state of the door and produces an appropriate GUI image to tell you what to do with it.

The error that keeps popping up tells me that Unity is expecting ), found ‘=’.

Am I doing something wrong and can anyone suggest how I can streamline this script?

enter code here

enum doorState {open, closed, locked};
var openImage:Texture2D;
var closeImage:Texture2D;
var lockedImage: Texture2D;
var showImage : boolean;
var openSound : AudioClip;
var closeSound : AudioClip;
var currentdoorState : doorState;


function OnTriggerStay () {
    	showImage = true;
		
		if (currentdoorState : doorState.closed){
		if (Input.GetKeyDown("e")){
        animation.Play("dooOpen");
        audio.PlayOneShot (openSound);
		var currentdoorState = doorState.open;
		}
		}
		
		if (currentdoorState : doorState.open) {
		if (Input.GetKeyDown("e")){
		animation.Play("doorClose");
		audio.PlayOneShot (closeSound);
		currentdoorState = doorState.closed;
		}
		}
		
		if (currentdoorState : doorState.locked){
		if (Input.GetKeyDown("e")){
		audio.PlayOneShot (lockedSound);
		}
		}
		
    
	}

function OnGUI (){
	if (currentdoorState : doorState.closed) {
		GUI.Button (Rect (Screen.width /2-75, Screen.height/2+200, 150, 150), openImage);
	
	if(Input.anyKeyDown){
   showImage = false;
	}
	
	if(currentdoorState : doorState.open) {
		GUI.Button (Rect (Screen.width /2-75, Screen.height/2+200, 150, 150), closeImage);
	}
	
	if(currentdoorState : doorState.locked) {
		GUI.Button (Rect (Screen.width /2-75, Screen.height/2+200, 150, 150), lockedImage);
	}
}
}

if (currentdoorState : doorState.closed){

is that acceptable syntax? did you try

  if (currentdoorState == doorState.closed){

also

    audio.PlayOneShot (openSound);
   var currentdoorState = doorState.open;

get rid of ‘var’ there.