Enemy waves

So I'm a bit stuck on a game I'm making. At one part in the game I'd like to have some sort of enemy wave system (like a tower defense type of game, or beat 'm up like streets of rage). You enter an area and a certain amount of enemies need to be defeated to proceed to the next area. These enemies will be events that walk around the map in a random way.

I'm not really sure how to do this. The event enemies are no problem. But I'd like them to respawn after a set amount of time so that even when you defeat the required amount, it's possible you encounter some more while walking to the exit. I'm also not sure how to count the amount of enemies I've defeated.
I'd like to know about the possibilities too. So may i leave comment here to watch future answers.
when you make the enemy encounter, put a control variable that adds 1 to the amount of enemies killed. say that it's called kill count
if you have the correct amount of kill count then you should be able to pass through
to do that you could make a parallel event that checks if the variable kill count is the correct amount

if you want to make them respawn, just set a timer on them and they should respawn
did you catch all that?
Event sheet 1
◆Battle Processing:Bat*2
:If Win
◆Control Variables:#0040 kill count += 1
◆Control Self Switch:A = ON
◆
:If Lose
◆
:End

Event sheet 2
◆Wait:60 frames
◆Control Self Switch:A = OFF

Map event set to parallel
◆If:kill count = x
◆Comment:you may proceed
◆
:End

x for number of kills
Event sheet 1
◆Battle Processing:Bat*2
:If Win
◆Control Variables:#0040 kill count += 1
◆Control Self Switch:A = ON
◆
:If Lose
◆
:End

Event sheet 2
◆Wait:60 frames
◆Control Self Switch:A = OFF

Map event set to parallel
◆If:kill count = x
◆Comment:you may proceed
◆
:End

x for number of kills

Thanks! I didn't even think about making a variable myself. I'm not sure I'm following with the self switch part. So when you win it turns on and after 60 frames it turns off. Does that mean that the event will reset? Shouldn't I mention the self switch in the first event sheet too?
the second sheet should need the self switch requirement, if the self switch isn't on it'll go to the first sheet

Original thread: https://forums.rpgmakerweb.com/threads/enemy-waves.78811/