This is not my script, i got it from dev forum https://devforum.roblox.com/t/how-to-check-if-enemy-npc-is-dead/1141643 , and it looks wrong, but i cant tell why, it doesnt work in game too. Can you supplement this script, tell me what to throw where, should it be a regular or local script?
Folder.ChildRemoved:Connect(function() if #Folder:GetChildren() == 0 then print("Hello world!") end end)
local RS = Game.GetService ("replicatedStorage") local folder = workspace.enemy_folder --a folder in workspace where enemies are grouped together local enemy = RS.Enemy:Clone() --a generic enemy model copied from a template in RS enemy.parent = folder enemy position = -- somewhere folder.ChildRemoved:Connect(function() --when an enemy is killed if #folder:GetChildren() == 0 then --if all of the enemies are dead print("Hello world!") else print(#folder:GetChildren()) -- print how many are left end end)