Help with door controller project

I have a project for school to make a doorbell for a pharmacy. when someone rings the bell a led lights up in the pharmacy and when the pharmacist pushes a button the led goes out and the door opens. but when the pharmacist doesn't open whitin 5min (2,5sec in my program) a buzzer goes off untill the door is opened.
my problem is that i cant open the door untill the buzzer goes off.

#include <Servo.h>

byte ledpin = 12;
byte button1 = 6;
byte button2 = 7;
const int buzzer = 5; //buzzer to arduino pin 5

int buttonState1;
int buttonState2;

Servo mijnServo;

void setup() {
pinMode(ledpin, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(buzzer, OUTPUT); // BuzzerPin declareren ls output

mijnServo.attach(8);

Serial.begin(9600);

// seconden, minuten, uren, dag vd week, dag vd maand, maand, jaar
//RTC.setDS1302Time(35, 42, 17, 6, 25, 05, 2020);
}

void loop()
{
buttonState1 = digitalRead(button1);
delay(10); // Kleine delay voor contactdender
buttonState2 = digitalRead(button2);
delay(10); // Kleine delay voor contactdender

if (buttonState1 == LOW)
{
digitalWrite(ledpin, HIGH);
delay(2500); // 5 min = 30 000
tone(buzzer, 1000); // Send 1KHz sound signal...
mijnServo.write(90);
}

if (buttonState2 == LOW)
{
digitalWrite(ledpin, LOW);
noTone(buzzer); // Stop sound...
mijnServo.write(180);
delay(2000);
mijnServo.write(90);
}
}

Hoi maartenf34, en welkom !

Please take some time to read this forums manual (click !)
It will help you to use the forum the best way possible, and how you can help us helping you.

Your problem is that you look for button1 to be pressed, after which you go to a fixed piece of code that has to be handled without any dependencies.
So button1 always invokes the LED to be lit, always waits 2.5 seconds, and always sounds the buzzer.
Once in that part of your code, there's no way to avoid any of the mentioned steps above.
Only after you have left that part, you will check button2 which will, if pressed, stop the buzzer and move something to open the door.

You need some extra steps in the part where you look for button1 to be pressed.

By the way, the delays supposed to handle bounce (contactdender) make no sense at all, and will not do what you seem to expect it to do.
There will be some more things to smooth out your sketch and be smart about some possibilities with those buttons, but that's for later.

Wanneer je dit liever in het Nederlands wil afhandelen, moet je op report to moderator onder je post klikken (of hier), en vragen of dit onderwerp naar het Nederlandstalige deel verplaatst kan worden.

This is a modification of your code based on the above comment. It'll do everything apart from the servos (Easy enough to figure out)

#include <Servo.h>

#define ledpin 12
#define button1 6
#define button2 7
#define buzzer 5
#define minutesToWait 5

bool running = false;
unsigned long prevTime;
Servo mijnServo;

void setup() {
  pinMode(ledpin, OUTPUT);
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  
  mijnServo.attach(8);
  
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(button1)) { //The doorbell has been rung
    running = true;
    digitalWrite(ledpin,HIGH);
    prevTime = millis();
  }
  
  if (digitalRead(button2)) { //The pharmacist has turned off the doorbell
    running = false;
    digitalWrite(ledpin,LOW);
    noTone(buzzer);
  }
  
  if (running && (millis() - prevTime >= minutesToWait*60000)) { //The timer has gone off
    tone(buzzer, 1000);
  }
}

Trust me, learning how to use timers and multitask the arduino effectively using them is a CRITICAL skill that may seem a little pointless now, but will save your skin MANY times later on down the line

It's clearly told it is a school project.

TS has now learned to copy someone else's code to finish their project.
If asked how it works, the answer has to be "by some magic i found online".