Resetting a Loop after an event

I'm trying to set up a visual alarm that goes off if a person comes within a certain distance of the sensor. However, I don't want the alarm constantly going off while the person is within range (anywhere from 30 seconds to tens of minutes).

How would I make it so it goes through the Alarm block, then waits until the person leaves before resetting and going off when another person comes by later? Here's my code so far:

#include <Wire.h>

#include "SparkFun_VL53L1X_Arduino_Library.h"
VL53L1X distanceSensor;

const int OfficeLight = 3 ;  //Office Strobe to Pin 3
const int LaundryLight = 4 ; //Laundry Strobe to Pin 4

void setup(void)
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("VL53L1X Qwiic Test");

  if (distanceSensor.begin() == false)
    Serial.println("Sensor offline!");
}

void loop(void)
{
  //Poll for completion of measurement
  while (distanceSensor.newDataReady() == false)
    delay(5);

  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor

  float distanceInches = distance * 0.0393701;
  float distanceFeet = distanceInches / 12.0;

  //Alarm
  if (distanceFeet <= 12) {
    for (int a=0; a < 2; a++){
      Serial.println("Person at Desk");
      digitalWrite(OfficeLight, HIGH);
      digitalWrite(LaundryLight, HIGH);
       delay(1000);
      digitalWrite(OfficeLight, LOW);
      digitalWrite(LaundryLight, LOW);
       delay(3000);
    }
  }

}

Add a boolean variable, at global scope, alarmSounded, initialized to false.

  if (distanceFeet <= 12 && !alarmSounded)
  {
    for (int a=0; a < 2; a++)
    {
       Serial.println("Person at Desk");
       digitalWrite(OfficeLight, HIGH);
       digitalWrite(LaundryLight, HIGH);
       delay(1000);
       digitalWrite(OfficeLight, LOW);
       digitalWrite(LaundryLight, LOW);
       delay(3000);
    }
    alarmSounded = true;
  }
  else
     alarmSounded = false;

See File->Examples->02.Digital->StateChangeDetection. You want an alarm when the state changes from Nobody There to Somebody There.

PaulS:
Add a boolean variable, at global scope, alarmSounded, initialized to false.

  if (distanceFeet <= 12 && !alarmSounded)

{
   for (int a=0; a < 2; a++)
   {
      Serial.println("Person at Desk");
      digitalWrite(OfficeLight, HIGH);
      digitalWrite(LaundryLight, HIGH);
      delay(1000);
      digitalWrite(OfficeLight, LOW);
      digitalWrite(LaundryLight, LOW);
      delay(3000);
   }
   alarmSounded = true;
 }
 else
    alarmSounded = false;

Awesome thanks for the help! Didn't know about state changes.