how to detect change of state within a period of time.

how to write a code if the button state won't change within 5 seconds LED will light up.

this is continuously checking whether HI or LO, ive already research about millis() function but cant figure out the use.

I know where to put the code but cant create the statement. please help

Let's suppose that you want to detect a change of state from HIGH to LOW

Each time the HIGH to LOW change occurs save the value of millis() and set a boolean to true. Any time that the input is LOW set the boolean to false.

Each time through loop() if the boolean is true check whether 5 seconds has elapsed since timing started. If so then set the boolean to false to prevent further triggering and run any other required code

Something like this pseudo code

void loop() {
  buttonState = read button
  if (buttonState == wrong) {
      mostRecentWrongStateTime = millis()
  }

  if (millis() - mostRecentWrongStateTime > desiredInterval) {
     // button has been in the correct state throughout the interval
  }
}

...R