local spawns = script.Parent
local spawnTime = 20
local maxZombies = 10
local currentTime = 0
local isNightTime = false
local zombieCount = 0
local function checkIfNight()
return currentTime >= 18 or currentTime <= 7
end
local function updateZombieCount()
zombieCount = 0
for _, obj in pairs(workspace:GetChildren()) do
if obj.Name == "Zombie" and obj:IsA("Model") then
zombieCount = zombieCount + 1
end
end
end
while true do
wait(spawnTime)
updateZombieCount()
isNightTime = checkIfNight()
if isNightTime and zombieCount < maxZombies then
for _, spwn in pairs(spawns:GetChildren()) do
if spwn:IsA('BasePart') then
local zombieCopy = game.ReplicatedStorage['Zombie']:Clone()
zombieCopy.Parent = game.Workspace
zombieCopy.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0, 3, 0))
end
end
end
end
** You are now Level 1! **