Making a maximum amount of password attempts on keypad door lock

Hi, I've made a keypad lock (with a motor turning the lock instead of a solenoid) The access works well and so does the code to unlock it but I want to make restrictions.

I'm rather new to this but I've declared :
int wrong = 0; // bad attempt
int total = 0; // counting bad attempts Not sure if I need this.

I've included several different working codes to open the door, please excuse the one called override, the plan was to ovreride the 3 strike lock out duration but I will make a separate post for it.
At the very end of the code is where I start using "Wrong" and want to test it with "ledPin, HIGH"

I've read through the posting guidelines and I hope I'm doing this right. Thank you to anyone for your input.

#include <Keypad.h>
#include <Password.h>
const byte myRows = 4;  // rangers
const byte myCols = 3;  //columns

char keys[myRows][myCols] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
}; //keypad layout

byte rowPins[myRows] = {12, 11, 10, 9 }; // first four aduino pins from side as per paper sketch 12 red 9 white, # white on keypad
byte colPins[myCols] = {8, 7, 6 }; // wire reverse from keypad 8 red 6 yellow * red on keypad

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, myRows, myCols ); //access library for keypad

char inputArray[5]; // changed it to include the star as part of the password
char Access[5] = {'1','4','2','5','*'}; //universal password
char Two[5] = {'2','4','6','8','*'}; // password b 
char Override[5] = {'1','2','3','4','5'}; // override pour ouvrir et ignorer le lockout. 


#define ledPin 4 //led to register keypad presses
#define motorPin 3 // motor
#define greenPin 2 //led that registers correct password entry

int i = 0;
int state = 1; //Creates the state
int wrong = 0; //  bad attempt
int total = 0; // counting bad attempts
void setup()
{
Serial.begin(9600); //open serial porrt
pinMode(ledPin, OUTPUT); //define led pin as output
pinMode(motorPin, OUTPUT); //define led pin as output
pinMode(greenPin, OUTPUT);

}

void loop()
{
{
 
while (state = 1)

 {
     
     
 char key = kpd.getKey();

 //if a key is pressed
   if(key)
     {

     //turn on ledPin
     digitalWrite(ledPin, HIGH);
     delay(100);
     digitalWrite(ledPin, LOW);
     delay(100);
     inputArray[i] = key; //store entry into array
     i++;
     Serial.println(key); //print keypad character entry to serial port

     if (key=='#')
       {
         Serial.println("Reset");
         i=0; //reset i
       }

     if (i == 5) //if 4 presses have been made
       {
         {

         //match input array to password array

           if (inputArray[0] == Access[0] &&
           inputArray[1] == Access[1] &&
           inputArray[2] == Access[2] &&
           inputArray[3] == Access[3])
              {
               digitalWrite(motorPin, HIGH); //turn on motorPin led
               digitalWrite(greenPin, HIGH);
               delay(5000);
               digitalWrite(motorPin, LOW);
               digitalWrite(greenPin, LOW);
              }
         }
         
         {

         //match input array to password array

           if (inputArray[0] == Two[0] &&
           inputArray[1] == Two[1] &&
           inputArray[2] == Two[2] &&
           inputArray[3] == Two[3])
              {
               digitalWrite(motorPin, HIGH); //turn on motorPin led
               digitalWrite(greenPin, HIGH);
               delay(4000);
               digitalWrite(motorPin, LOW);
               digitalWrite(greenPin, LOW);
              }
         }
         
         {

         //match input array to password array /////////////////////////////OVERRIDE

           if (inputArray[0] == Override[0] &&
           inputArray[1] == Override[1] &&
           inputArray[2] == Override[2] &&
           inputArray[3] == Override[3])
              {
                digitalWrite(motorPin, HIGH); //turn on motorPin led
               digitalWrite(greenPin, HIGH);
               delay(4000);
               digitalWrite(motorPin, LOW);
               delay(1000);
               digitalWrite(greenPin, LOW);
               digitalWrite(ledPin, HIGH);
               delay(1000);
               digitalWrite(ledPin, LOW);
               digitalWrite(greenPin, HIGH);
               delay(1000);
                digitalWrite(greenPin, LOW);
               digitalWrite(ledPin, HIGH);
               delay(1000);
               digitalWrite(ledPin, LOW);
               digitalWrite(greenPin, HIGH);
               delay(1000);
               digitalWrite(ledPin, LOW);
               digitalWrite(greenPin, LOW);
              }
         }
         
         {
         i=0; //reset i
         }
       }
     
     }
   };
  }
 
{
 
 while (state = 2)

 {
     
     
 char key = kpd.getKey();

 //if a key is presseds
   if(key)
     {

     //turn on ledPin
     digitalWrite(ledPin, HIGH);
     delay(100);
     digitalWrite(ledPin, LOW);
     delay(100);
     inputArray[i] = key; //store entry into array
     i++;
     Serial.println(key); //print keypad character entry to serial port

     if (key=='#')
       {
         Serial.println("Reset");
         i=0; //reset i
       }

     if (i == 5) //if 5 presses have been made
       {
         { 

         //match input array to password array greenPin

           if (inputArray[0] == Access[0] &&
           inputArray[1] == Access[1] &&
           inputArray[2] == Access[2] &&
           inputArray[3] == Access[3])
              {
               digitalWrite(motorPin, HIGH); //turn on motorPin led
               digitalWrite(greenPin, HIGH); //turn on motorPin led
               delay(4000);
               digitalWrite(motorPin, LOW);
               digitalWrite(greenPin, LOW);
              }
         }
         
         
         
         {
         i=0; //reset i
         wrong=0;
         }
       }
       else 
       {
        wrong++;
       }
       if (wrong == 2)
        {digitalWrite(ledPin, HIGH);
          delay 5000;
        }
     }
   };
 
}
 
 
}

I've read through more posting guidelines so I'll add, what I'm trying to do specifically: I'd like to know how to make my "wrong" count wrong attempts. I currently does nothing, the lock program runs fine and I'm not getting any errors. But I have unlimited attempts and that's not what I want.

else
{
wrong++;
}
if (wrong == 2)
{digitalWrite(ledPin, HIGH);

On your closing of brackets I dont think you should have this"
}

}
};

}
"
You should have this
"

}

}
}
}

Thank you, I removed it, but nothing has changed. The rest of the program still runs well.

Consider this pseudo code:

allowed = true;
wrong_attempt = 0;

void loop()
{
   if (allowed) {
      password = read_password();
      correct = validate_password(password);
      if (correct) {
         open_lock();
         wrong_attempt = 0;
      } else {
         wrong_attempt++;
         if (wrong_attempt >= MAX_ATTEMPT) {
            allowed = false;
         }
      }
   } else {
      //handle system locked out here
      //maybe wait 5 minutes and enable system again
      wait_5_minutes();
      allowed = true;
   }


}

Thank you, I see the similarity but to be honest I'm not sure how it related to how I'm using passwords in my program. If it would work for what I'm doing I can't figure out where to substitute the terminology.