Unlock door when player or headcrabs die. How to make it?

Hello
I wanna make headcrabs trap. There is small room with the button. When player enter room he see button on the wall>he pressing it>door locking>headcrabs unburrow and attacking him - that i’ve made myself. I need to make when player or all headcrabs will die the door will unlock.
How to make it?

I will now assume that you have 4 headcrabs. This will work with any amount of headcrabs but let’s say you have four.

Make a math_counter and give it the following keyvalues:

Name: counter
Start disabled: no
Initial value: 0
Minimum legal value: 0
Maximum legal value: 4

Then go to its outputs and put the following output there.

OnHitMax | door | unlock

And then select your headcrabs and give ALL OF THEM this output.

OnDeath | counter | Add | 1

Now the door will unlock when all the headcrabs are dead.
If the amount of headcrabs you have is not 4, you can change the “Maximum legal value” of your math_counter to correspond with the amount of headcrabs.

No idea how to make it unlock when the player dies. Maybe a trigger_multiple with the following output:

OnEndTouchAll | door | unlock

Perhaps that would work? Not sure.

You could use onDamaged?
Depends on what is used to kill the headcrab

Miigga’s method is what I had in mind. Can you put in an override parameter for onDamaged that specifies the headcrabs health? (100)