Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you supplement this if enemy is dead script please?

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)

1 comment

0

Yeah, i suck in scripting BADLY, my maximum is a gate that can open when collected 3 keys, dont yell pls

1 answer

✓ Accepted answer
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)

2 comments

0

It should be a normal script

0

Thank you very much!

This discussion is preserved as it was. New answers, comments, and votes are closed.