Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years 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. User#834 0 — 4y
0
I don't know how to access it. zandefear4 90 — 4y
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 90 — 4y

1 answer

Log in to vote
0
Answered by 4 years 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