How to Restart Sequence to an array

Hi there, Im just learning Arduino and I was wondering how to restart an array sequence with a second pushbutton.

I have made several attempts and I cant figure it out. If someone could explain how, I highly would appreciate it.

What I am trying to attempt is to have when one push button is pressed it will turn on the next led in the array. When pushbutton 2 is pressed, Id like it to restart the sequence.

const int buttonPin = 2; // the pin number of the pushbutton input pin
const int buttonOff = 8;
int ledPins[] = {3, 4, 5, 6, 7};  // variables will change:
int onbuttonState = 0; // variable for reading the pushbutton status
int offbuttonState = 0;
int buttonPressCount = 0;
int buttonPressCount2 = 0;
int numberOfLED = 5;
void setup() {
  // initialize the LED pin as an output:
  for (int i = 0; i < numberOfLED; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
  pinMode(buttonPin, INPUT);
}
void blink() {
  if (onbuttonState == LOW) {  // check if the pushbutton is pressed.
    for (int i = 0; i < numberOfLED; i++) {
      if (buttonPressCount % numberOfLED == i) {
        digitalWrite(ledPins[i], HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);              // wait for a second
        digitalWrite(ledPins[i], LOW);    // turn the LED off by making the voltage LOW
      }
    }
  }
}
void loop() {
  offbuttonState = digitalRead(buttonOff);
  onbuttonState = digitalRead(buttonPin);  // read the state of the pushbutton value
  if (onbuttonState == LOW) {  // check if the pushbutton is pressed.
    for (int i = 0; i < numberOfLED; i++) {
      if (buttonPressCount % numberOfLED == i) {
        blink();
      } else {
        digitalWrite(ledPins[i], LOW); // turn LED off
      
      }
    }
    buttonPressCount++;
    delay(400);
  }
}

Did you made halve of it italic? Don't think so. Please edit the post to use code tags. See How to use this forum.

Explain more clearly what you expect the code to do, and what it actually does - don't assume
we know what you mean by "restart an array sequence with a second pushbutton"

The code in blink() seems to do the same thing with the LED whatever the value of buttonPressCount, which
can't be intentional.

Or maybe that's due to us not seeing your array indexing because you didn't use code tags, so we get italics instead...

Ah, now its code tagged, but it doesn't compile....

I think you are just asking how to set buttonPressCount to zero?
That's easy - set it to zero...

Also why the loops? Surely you mean

  digitalWrite (ledPins [buttonPressCount % numberOfLED], HIGH) ;
  delay (1000) ;
  digitalWrite (ledPins [buttonPressCount % numberOfLED], LOW) ;

Sorry, what I am trying to do is with Pushbutton One each time it is pressed the next Led will come on for a second.

If a second pushbutton is pressed, it will restart the sequence.

MarkT:
I think you are just asking how to set buttonPressCount to zero?
That's easy - set it to zero...

Also why the loops? Surely you mean

  digitalWrite (ledPins [buttonPressCount % numberOfLED], HIGH) ;

delay (1000) ;
  digitalWrite (ledPins [buttonPressCount % numberOfLED], LOW) ;

Thanks Mark, I was overthinking this all I had to do was just add another if statement for the second pushbutton and if it reads low it will thn set the buttonpresscount to 0