Everytime I try and make it work, only ONE of the lights actually works across the whole map instead of each of them. I assume there is something wrong with the script since all of them are named correctly and stuff.

local Time = game:GetService("Lighting")
local Windows = {}
for i,v in next, workspace:GetDescendants() do
    if v.Name == 'Brightness' then
       table.insert(Windows,v)
    end
end

GetStatus = function()
    local Min = math.abs(Time:GetMinutesAfterMidnight())
    local N1 = 0
    local D1 = 195
    local D2 = 1800
    if (Min >= N1 and Min < D1) then
        return "Night"
    elseif (Min >= D1 and Min < D2) then
        return "Day"
    elseif (Min >= D2) then
        return "Night"
    end
end
Update = function()
    local Status = GetStatus()
    if (Status == "Day") then
        for i,v in next, Windows do
            if v.Name == 'Brightness' then
                v.Spotlight.Enabled = false
					v.Spotlight2.Enabled = false
						v.Fire.Enabled = false
							v.Glow.Enabled = false
								v.Smoke.Enabled = false
            end
        end
    elseif (Status == "Night") then
        for i,v in next, Windows do
            if v.Name == 'Brightness' then
                v.Spotlight.Enabled = true
					v.Spotlight2.Enabled = true
						v.Fire.Enabled = true
							v.Glow.Enabled = true
								v.Smoke.Enabled = true
            end
        end
    end
end
Time.Changed:Connect(Update)

3 comments

0

What. Is. This. Are all of your lights named "Brightness"?

0

also, i don't think that's proper indentation

0

maybe change "for i,v in next, workspace:GetDescendants() do" on line 3 to "for i,v in next, #workspace:GetDescendants() do"