Can't get my code to work any suggestions?

const int buttonPin = 7;
int buttonState = 0;
int ledpins[5]={2,3,4,5,6};
int val = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  for(int i=0; i<5; i++){
    pinMode(ledpins[i],OUTPUT);
 
  
  }
}

void loop() {

  for(int i=0; i<5; i++){
    digitalWrite(ledpins[i], HIGH);
    delay(25);
    digitalWrite(ledpins[i], LOW);
  }
  val = digitalRead(buttonPin);
  if (val == HIGH){
    delay(3000);
  }
 

}

What i am trying to achieve is in tinkercad is to when i press the button there is a pause of 3 seconds on the led it’s currently on.

How is your button wired? To GND or +5?

You are only turning all the LEDs on for 25 milliseconds so you will not not see them. You are pausing when the input is HIGH but since we don't know how your button is wired we can't know if that is correct or not.

I would suggest using INPUT_PULLUP and wiring the button to GND.

This is my https://imgur.com/a/CpjlX1m it won't let me post images directly sorry but i use a pullup now and use the wiring to - but it refuses to do what i want

Most people won't go to a web address. Can you attach the picture?

|500x290

I need to wait 5 minutes for a post sorry but this should work i think i'm using INPUT_PULLUP rn but all it does now is just delay the whole array for 3s but what i'm trying to achieve is to pause the array on it's current led that's on for 3 seconds, i'm kinda amateur to C++ so i couldn't find anything over the whole web on this subject.

You were not using INPUT_PULLUP. It is wired so the button is active LOW which means the input is a LOW when the button is pushed. Try this:

const int buttonPin = 7;
int ledpins[5]={2,3,4,5,6};
int val = 0;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  for(int i=0; i<5; i++){
    pinMode(ledpins[i],OUTPUT);
  }
}

void loop() {
  static int ledIndex = 0;
  byte buttonState;
  digitalWrite(ledpins[ledIndex], HIGH);
  delay(25);
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW)
  {
    delay(3000);
  }
  digitalWrite(ledpins[ledIndex], LOW);
  ledIndex++;
  ledIndex %= 5;
}

If you want the LEDs to go slower while you are not pressing the button then change delay(25) to something else.

Owh thx looks like i was pretty off with my code wow