Hello!
I made a script that is supposed to turn a light on at night and off during the day. There are no noticeable errors in the script, but when I join the game during the daytime, the light is still on when it should be off.
This is the script:
local part = script.Parent
local spotLight = part.SpotLight
while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 then
part.Material = Enum.Material.Plastic
spotLight.Enabled = false
end
if game.Lighting:GetMinutesAfterMidnight() > 18 *60 then
part.Material = Enum.Material.Neon
spotLight.Enabled = true
end
end