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?
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