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

TimeOfDay detecting part of script not working?

Asked by 7 years ago
local light = script.Parent
local timeofday = game.Lighting.TimeOfDay

while true do
    wait(1)
    if timeofday > "17:45:00" and timeofday < "06:20:00" then
        print("its night")
        light.Angle = 180
        light.Brightness = 10
        light.Range = 12
    else
        print("its day")
        light.Angle = 0
        light.Brightness = 0
        light.Range = 0
    end
end

The output keeps on printing that it's day..

I don't get how to fix it. is it because of comparing with strings instead of numbers? And if it is, how would i convert time of day to numbers? It doesn't let me write the time of day as a number without an error.

1
You can convert it to a number with GetMinutesAfterMidnight. http://wiki.roblox.com/index.php?title=API:Class/Lighting/GetMinutesAfterMidnight XAXA 1569 — 7y
0
Thanks XAXA! That helped, and now my script works VeryRaven 85 — 7y

Answer this question