so i got this script that controls the main spawning for zombies
local CS = game:getService("CollectionService")
while true do
wait(5)
for i, v in pairs(CS:GetTagged("spawner")) do
if game.ReplicatedStorage.Values.gameInProgress.Value == true then
if game.ReplicatedStorage.Values.zombiesRemaining.Value > 0 then
local NPC = game.ReplicatedStorage.Zombie:Clone()
NPC.Parent = v
NPC.HumanoidRootPart.CFrame = v.CFrame
CS:AddTag(NPC, "Zombie")
game.ReplicatedStorage.Values.zombiesRemaining.Value = game.ReplicatedStorage.Values.zombiesRemaining.Value - 1
end
end
end
end
but i want to make a cap of like 24 - 30 zombies allowed at a time. when the rounds get higher too many zombies spawn into the map. but i dont know how to write it out. an idea i had was this
local CS = game:getService("CollectionService")
while true do
wait(5)
for i, v in pairs(CS:GetTagged("spawner")) do
if game.ReplicatedStorage.Values.gameInProgress.Value == true then
if game.ReplicatedStorage.Values.zombiesRemaining.Value > 0 then
local NPC = game.ReplicatedStorage.Zombie:Clone()
NPC.Parent = v
NPC.HumanoidRootPart.CFrame = v.CFrame
CS:AddTag(NPC, "Zombie")
game.ReplicatedStorage.Values.zombiesRemaining.Value = game.ReplicatedStorage.Values.zombiesRemaining.Value - 1
end
if game.ReplicatedStorage.Values.gameInProgress.Value == true then
if game.ReplicatedStorage.Values.zombiesRemaining.Value < 24 then
end
end
end
end
end
but i honestly dont know how to write out "stop spawning" .

1 comment
Did you make this code?