Have a function that fires every time an enemy is killed. Make it lower the count by one, update the visible count for the players, and check if the count is zero. If the count is zero, run the code to move on to the next wave or whatever you want to do next.
You can detect when a zombie is removed from the zombie folder or the place where u store zombies, using:
Instance.DescendantRemoving:Connect(function(removing)
if removing.Name == "Zombie" then --change this
UpdateCounter() -- A function that updates the counter
end
end)
local zombie = workspace.Zombie
local ZombiesLeft = script.Parent.ZombiesLeft
zombie.Humanoid.Died:Connect(function()
subtractZombie()
end
function subtractZombie()
ZombiesLeft.Value = ZombiesLeft.Value - 1
plr.PlayerGui.YOURTEXTBOX.Text = ("Zombies left: ")..ZombiesLeft.Value
end
also you would have to do some work to this script but it is your basis, use numbervalues, functions, and Humanoid.Died
Create a numbervalue in workspace (i named it enemy) then in gui textlabel add localscript
while true do
script.Parent.Text = "enemies(or smth u need to write extra): ".. game.Workspace.enemy.Value
After that you need script that will count amount of enemies or change it
I added a folder in workspace in that will be enemies after spawning so using this script in workspace again