Yeah, it does. I’m not entirely sure what’s causing the zombies to not spawn because there aren’t any errors.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnDelta = os.clock()
local SpawnCooldown = 10
-- Set the duration of each day and night cycle (in seconds)
local dayDuration = 60
local nightDuration = 30
-- Set the time when night starts (in hours, 24-hour format)
local nightStartHour = 20
local nightEndHour = 6
-- Set the zombie spawn location
local zombieSpawnLocation = Vector3.new(-63.078, 0.5, 631.332)
-- Load the zombie model from ReplicatedStorage
local zombieModel = ReplicatedStorage:WaitForChild("Zombie"):Clone()
-- Function to spawn zombies
local function spawnZombies()
local zombie = zombieModel:Clone()
zombie.Parent = workspace
zombie:SetPrimaryPartCFrame(CFrame.new(zombieSpawnLocation))
end
-- Function to switch between day and night
local function switchDayNight()
if Lighting.ClockTime >= nightStartHour or Lighting.ClockTime < nightEndHour then
print("time updated")
-- It's night, spawn zombies
if os.clock() - SpawnDelta > SpawnCooldown then
SpawnDelta = os.clock()
spawnZombies()
end
end
end
-- Function to update the time
local function updateTime(deltaTime)
Lighting.ClockTime = Lighting.ClockTime + deltaTime / 10
end
-- Connect the functions to the appropriate events
game:GetService("RunService").Heartbeat:Connect(updateTime)
game:GetService("RunService").Heartbeat:Connect(switchDayNight)```