How to check if Enemy NPC is dead?

I am trying to make a Dungeon Quest type game where you have to fight a group of enemies to unlock the next room. How can I check if all the enemy npcs are dead? I’ve considered looping through every enemy in a folder and if there is none then the next door would open. But I’m not sure how to do that/if that would work.

2 Likes

If the waves of enemies are in a folder and they have code to despawn after a while, you could check whenever a child is removed from the folder and if there are no more children in that folder (all enemies dead), you can do something

Folder.ChildRemoved:Connect(function()
	if #Folder:GetChildren() == 0 then
		--Do something
	end
end)
3 Likes