dont know how to approach this.

I’ve been trying to get the program to turn the relay pin on and off when button two and four are in the same state. meaning when 2 and 4 are both off the relay pin is on or vice-versa.
this is all I have so far.

const int buttonPin[] = {2,3,4};     // the number of the pushbutton pins
const int relayPin =  11;// the number of the relay pin
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(relayPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  for(int x=0; x<2; x++)
  {
    pinMode(buttonPin[x], INPUT); 
  }  
}

void loop(){
  // read the state of the pushbutton value:
  for(int x=0; x<2; x++)
{
    buttonState = digitalRead(buttonPin[x]);

    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
   
    if (buttonState == LOW && buttonPin[x] == 2) {    
      // turn LED on:   
      digitalWrite(relayPin, LOW); 
    }
    if (buttonState == HIGH && buttonPin[x] == 2) {    
      // turn LED on:   
      digitalWrite(relayPin, HIGH); 
      }
    if (buttonState == LOW && buttonPin[x] == 4) {    
      // turn LED on:   
      digitalWrite(relayPin, LOW); 
    }
    if (buttonState == HIGH && buttonPin[x] == 4) {    
      // turn LED on:   
      digitalWrite(relayPin, HIGH); 
    }
    if (buttonState == HIGH && buttonPin[x] == 3) {
      // turn LED off:
      digitalWrite(relayPin, LOW);
    }
   } 
 }

If you want to know that two pins are in the same state, you’re going to have to know the state of both pins at the same time. So you simply can’t do it the way you are doing it as you only read one button at a time here. You’ll need two buttonState variables, one for each of the two pins you want to compare.

Additionally with this code, buttonPin[x] can never be 4 because that’s the third pin and your for loop only iterates 2 times. You have x<2 as the condition, so it will only run for 0 and 1.