I’m still new to Lua, but I understand the concept of how some concepts work.
-
What do you want to achieve? I am attempting to create a window, in which when the game time is night, it glows; and when it is daytime the window doesn’t glow.
-
What is the issue? The issue is I start the game at night. When I set it to mid-day, the window does not turn back to non-neon. Vice-versa occurs when it starts from the day and I set it to night, where it doesn’t turn neon.
-
What solutions have you tried so far? I have tried playing with the time a bit, but I am not advanced at Lua; so I don’t know what else to change.
The “Time Check” does appear in the output log every 1 - 10 seconds, which is telling me the script is indeed going through.
local chance = math.random(1,2)
while true do
wait (math.random(1,10))
print "Time Check"
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
script.Parent.BrickColor = BrickColor.Black()
script.Parent.Material = Enum.Material.Glass
end
if game.Lighting:GetMinutesAfterMidnight() > 18 * 60
and chance >= 1.5
then
script.Parent.BrickColor = BrickColor.new("New Yeller")
script.Parent.Material = Enum.Material.Neon
end
end
I believe it could be something to do with the while true do
not including the if
statements after the first loop?