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

How do I check when all zombies are dead?

Asked by 4 years ago

I am making a zombie fighting game, and I want to reward players with a badge when every zombie in the server has been killed. How would I script something to check if the zombies are dead and to give players the badge?

0
Check out BadgeService for the award component—also, SAO, I pay my respects. Ziffixture 6913 — 4y
0
Not constructive comment bruh WilsonFactions -4 — 4y

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

I'll show you what I did for my zombie raid base game that I discontinued.

1. Create a file in workspace and name it "Zombies". Now use the code below in a serverscript!

local FileArea = game.Workspace.Zombies --Put your file thing here
local amount --Don't mess with this
local battle = false --Checks if zombie raid is ongoing

--Do zombie spawning and stuff. When spawning put them in the file.

wait()

battle = true --Turns on zombie raid

while battle do --Creates a repeating value if battle is active
wait() --waits so the repeat doesn't crash the game
for i,v in pairs(FileArea:GetChildren()) do --Gets all zombies in the Zombies file
    if #v == 0 then --Checks if zombies are all dead.
        battle = false --Stops the battle
        --End game. Do a GUI or something. Or put a badge
    end
end
end

Also if you don't know how to do the zombie delete thing. Use this below (Put it in the zombies humanoid)

script.Parent.Died:Connect(function() --Checks for death start
    script.Parent.Parent:Destroy() --Removes the zombie on death
end
0
Thank you! Kirito40000000000 7 — 4y
0
Please accept this answer Lakodex 711 — 4y
0
Im still new to this website, thank you for telling me. Kirito40000000000 7 — 4y
Ad

Answer this question