Assuming that you have a functioning day/night script already made, you can use the GetPropertyChangedSignal event with the ClockTime property of Lighting to achieve what you're looking for.
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:
01 | local LightingService = game:GetService( "Lighting" ) |
04 | local zombiesActive = false |
06 | local function ClockTimeChanged() |
07 | local newClockTime = LightingService.ClockTime |
12 | if (newClockTime > = TIME_DAY and newClockTime < TIME_NIGHT) then |
18 | elseif (newClockTime > = TIME_NIGHT or (newClockTime > 0 and newClockTime < TIME_DAY)) then |
25 | LightingService:GetPropertyChangedSignal( "ClockTime" ):Connect(ClockTimeChanged) |
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!