I keep getting errors while compiling my chicken door sketc, need help debugging

void loop(){ 

  averagelightLevel(){
   ...
  }
  ...
}

What exactly are you trying to do here?

You've defined averagelightLevel as a variable, and now you are trying to define it as a function. On top of that, you are trying to define it within another function, which doesn't work.

(avelight) = total

Parenthesis are completely unnecessary here

if (doordownpin) = HIGH

This is not how you write an if statement, I recommend looking at some of the examples on how to properly write one.

if (avelight) >= 600 (closeDoor);
if (avelight) <= 300 (openDoor);

This is also not how you call a function. Again, I recommend looking at example sketches on how to properly call one.

int doordownPin = 5; //Door down Limit swictch
int doorupPin = 6;  // Door up limit switch
int commanddoorUp = 8;  // Move the door to the up position
int commanddoorDown = 9;  // Move the door to the down position
...
if (doorupPin) = HIGH); 
(commanddoorDown) HIGH;
delay (2000);
if (doordownPin) != HIGH;

This is not how you check the state of a pin; you're checking the numbers of the pin against values HIGH and LOW. You need to be checking the state of the pin, which is done with digitalRead().

void fault(){
  ...
  fault();
}

Recursion without an exit condition is a big no-no (I'd also go as far as to say no recursion at all on the Arduino, considering the limited memory).

if (doorupPin) = HIGH);
  • Number of parenthesis doesn;t match.
    = is assignment, == is comparison.
    Semicolon at the end of an if statement means just check it, don't do anything based on the condition.