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

How do I check when all zombies are dead?

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?

2 comments

0

Check out BadgeService for the award component—also, SAO, I pay my respects.

0

Not constructive comment bruh

1 answer

✓ Accepted answer

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

3 comments

0

Thank you!

0

Please accept this answer

0

Im still new to this website, thank you for telling me.

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