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
01local light = script.Parent
02local timeofday = game.Lighting.TimeOfDay
03 
04while true do
05    wait(1)
06    if timeofday > "17:45:00" and timeofday < "06:20:00" then
07        print("its night")
08        light.Angle = 180
09        light.Brightness = 10
10        light.Range = 12
11    else
12        print("its day")
13        light.Angle = 0
14        light.Brightness = 0
15        light.Range = 0
16    end
17end

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