Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script only turns off the lights at 7AM, but they don't turn back on?

The lights only turn off and change to plastic at 7AM, but when It's 6PM, the lights don't turn back on. This is what I have.

local lightPart = game.Workspace.Lights:GetChildren()
game.Lighting.LightingChanged:connect(function()
    local timeAfterMidnight = game.Lighting:GetMinutesAfterMidnight()
    if timeAfterMidnight >= 7 * 60 and timeAfterMidnight <= 18 * 60 then
        for i,v in pairs(lightPart) do
                v.Material = Enum.Material.Plastic
                v.PointLight.Enabled = false
        end
	elseif timeAfterMidnight >= 18 * 60 and timeAfterMidnight <= 7 * 60 then
        for i,v in pairs(lightPart) do
                v.Material = Enum.Material.Neon
                v.PointLight.Enabled = true
        end
    end
end)

1 answer

Your second condition is always false : elseif timeAfterMidnight >= 18 * 60 and timeAfterMidnight <= 7 * 60 then

timeAfterMidnight can't be both above 18 * 60 and below 7 * 60 !

It's night if the timer is above 18 * 60 or if it's below 7 * 60

Use elseif timeAfterMidnight >= 18 * 60 or timeAfterMidnight <= 7 * 60 then

1 comment

0

Oops. Thanks though!

This discussion is preserved as it was. New answers, comments, and votes are closed.