So, I have a script that's suppose to enable other scripts when its day or night. It won't work, I have a script that changes the time every .1 seconds, so I know that's not the problem. Am I not suppose to check the Clock Time, or am I suppose to use a normal script? Then, I have 2 other scripts that enable the scripts that actually do something, when the event fires. But, it's still not working anyway.
This is my code, in a local script.
while true do local Event = game.ReplicatedStorage.Events wait() if game.Lighting.ClockTime >= 6.6 then if game.Lighting.ClockTime < 17.7 then Event.dayenable:FireServer() end end if game.Lighting.ClockTime <= 6.6 then if game.Lighting.ClockTime > 17.7 then Event.spawn2:FireServer() end end end
Second script, thats a normal one
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage.Events:WaitForChild("dayenable") local function Enable() script.Parent.Day.Disabled = false end remoteEvent.OnServerEvent:Connect(Enable)
I found that I have to use MinutesAfterMidnight, to change the time. The values of lighting, like clocktime, can't be changed by themselves, you have to use the minutes after midnight. Here's a full explanation: https://developer.roblox.com/en-us/api-reference/function/Lighting/SetMinutesAfterMidnight