Problem with adding button 2 a traffic light code

I tried to add a button to the below traffic light code but did not work. If buttonstate is HIGH, red and green lights go off while yellows go on.
Is that because of the code or that Arduino is busy, so it doesn’t respond to the button state?
Any help would be appreciated!

/* real_us_traffic_lights2.pde
   By: Daniel Wright
   2010.JAN.30
   MODIFIED
  */
const int buttonPin = 2;
int buttonState = 0;         // variable for reading the pushbutton status
int carRed1 = 13; // assign the car1 lights
int carYellow1 = 12;
int carGreen1 = 11;
int carRed2 = 10; // assign the car2 lights
int carYellow2 = 9;
int carGreen2 = 8;

void setup() {
pinMode(carRed1, OUTPUT);
pinMode(carYellow1, OUTPUT);
pinMode(carGreen1, OUTPUT);
pinMode(carRed2, OUTPUT);
pinMode(carYellow2, OUTPUT);
pinMode(carGreen2, OUTPUT);
pinMode(buttonPin, INPUT);

// initialize the lights
digitalWrite(carRed1, HIGH);
digitalWrite(carRed2, HIGH);
delay(4000);
}

void loop() {
   if (buttonState == HIGH) {     
    // turn LED on:    
digitalWrite(carGreen1, LOW);
digitalWrite(carGreen2, LOW); // 
digitalWrite(carYellow2, HIGH); //
digitalWrite(carRed1, LOW); //car red 1 off
digitalWrite(carGreen1, LOW); //car green 1 off
digitalWrite(carYellow1, HIGH); // car yellow 1 on
  } 
  else{
digitalWrite(carRed1, LOW); // car green 1 off
digitalWrite(carGreen1, HIGH); // car green 1 on
delay(5000); // wait for preset time period
// flash the ped yel 1
for (int x=0; x<4; x++) {
digitalWrite(carYellow1, HIGH);
delay(500);
digitalWrite(carYellow1, LOW);
delay(500);
}
digitalWrite(carGreen1, LOW); // car green 1 off
digitalWrite(carYellow1, LOW); // car yellow 1 off
digitalWrite(carRed1, HIGH); // car red 1 on

delay(2000); // wait 1 second till its safe

digitalWrite(carRed2, LOW); // car green 2 off
digitalWrite(carGreen2, HIGH); // car green 2 on
delay(5000); // wait for preset time period
// flash the ped yel 2
for (int x=0; x<4; x++) {
digitalWrite(carYellow2, HIGH);
delay(500);
digitalWrite(carYellow2, LOW);
delay(500);
}
digitalWrite(carGreen2, LOW); // car green 2 off
digitalWrite(carYellow2, LOW); // car yellow 2 off
digitalWrite(carRed2, HIGH); // car red 2 on

delay(2000); // wait 1 second till its safe

  }
}

During a delay() function call, loop halts. The button state is not being read.

You have states. Green light is on one way, while red is on the other ways. Then, after a time you transition to another state, where yellow lights replace the green light. The, another state where the red light is on where the green one was on. I'm sure you can figure out what the other states are.

During each pass through loop, you need to see if a button has been pressed, and/or you need to see if it is time to transition to another state. Look at the blink without delay example for how to do this.

Finally, you need to take actions for the current state, lighting appropriate LEDs.