I have tried so hard to make Zombies spawn at night and die in the day but it is so hard, If anyone knows how to do this that would be helpful as this is key to my game.
Once you've connected this event, you can use a debounce to keep the function from firing in later portions of the day.
An application of this can be found below:
local LightingService = game:GetService("Lighting") local TIME_DAY = 6 -- Set this to the hour you want the zombies to die local TIME_NIGHT = 18 -- Set this to the hour you want zombies to spawn local zombiesActive = false -- This is our debounce local function ClockTimeChanged() local newClockTime = LightingService.ClockTime if zombiesActive then -- If zombies are out, lets check if the ClockTime is day. if (newClockTime >= TIME_DAY and newClockTime < TIME_NIGHT) then zombiesActive = false -- PUT YOUR CODE TO DESPAWN THE ZOMBIES HERE end elseif (newClockTime >= TIME_NIGHT or (newClockTime > 0 and newClockTime < TIME_DAY)) then -- If zombies aren't spawned, we check if the ClockTime is night to spawn them. zombiesActive = true -- PUT YOUR CODE TO SPAWN THE ZOMBIES HERE end end LightingService:GetPropertyChangedSignal("ClockTime"):Connect(ClockTimeChanged) -- This is where we are making the connection to listen to when the time is changed. Once the time changes, the ClockTimeChanged function will fire.
The rest here is up to you. I've left comments in caps as indication of where to put your code.
If you have any questions, be sure to ask. Best of luck!