Help With Program for Line Following Robot

int sensorPin = A0;   // select the input pin for ldr
int sensorPin2 = A1;
int sensorValue = 0;  // variable to store the value coming from the sensor
int sensorValue2 = 0;

Do you count uh-huh, 2, 3, ...? Or do you count 1, 2, 3, ...?

When numbering seemingly related variables, number ALL of them. That will save you untold grief later on.

  sensorValue = analogRead(sensorPin);   
  Serial.println(sensorValue);
  sensorValue = analogRead(sensorPin2);   
  Serial.println(sensorValue2);

Like right there. You crap in sensorValue, and then print sensorValue2.

You also do NOT define what you are printing, so you are guessing when it comes time to compare the output to the program. Don't guess. Make the output crystal clear.

  digitalWrite(AO1,HIGH); //turn relay ON

When defining AO1, you claimed that is was connected to a motor driver. I'm willing to be that the motor driver does NOT use relays.