New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Day/night checking script doesn't do what its suppose to, when its day/night? (Answered)

Asked by 14 days ago
Edited 11 days ago

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)
0
Is there a reason why you need the ClockTime check in a localscript. The game clock is synced for all players. FloweryMonkeyboy5 603 — 14d
0
I don't know how to access it. zandefear4 93 — 14d
0
I know to change it, I have to use minutes after midnight. But I don't know how to check it in a local script. zandefear4 93 — 14d

1 answer

Log in to vote
0
Answered by 11 days ago

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

Ad

Answer this question