Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you supplement this if enemy is dead script please?

Asked by
Glvt102 11
3 years ago

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)
0
Yeah, i suck in scripting BADLY, my maximum is a gate that can open when collected 3 keys, dont yell pls Glvt102 11 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
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)
0
It should be a normal script AlexTheCreator 461 — 3y
0
Thank you very much! Glvt102 11 — 3y
Ad

Answer this question