Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i make it so all the lights turn off/on at a certain time?

Asked by 8 years ago
minutesAfterMidnight = 0
setLights = function()
    for i,v in next, workspace:GetChildren() do
        if v:IsA("SpotLight") then
            v.Enabled = true
        end
    end
end

while true do
    minutesAfterMidnight = minutesAfterMidnight + 10
    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
    wait(.1)
    if game.Lighting.TimeOfDay == "06:00:00" then
        setLights(false)
        end
    if game.Lighting.TimeOfDay == "18:00:00" then
        setLights(true)
    end
end

wat i have collected from others so far and edited..i have no idea how this works please explain//it is currently not working

1 answer

Log in to vote
1
Answered by 8 years ago

You're not taking an argument in your setLights function. Change it to this and maybe it will work.

function SetLightsEnabled(bool)
    local function GetAllLights(p)
        local lights = {}
        for _,v in next, p:GetChildren() do
            if v:IsA("Light") then
                table.insert(lights, v)
            end
            GetAllLights(v)
        end
    end
    for _,light in next, GetAllLights(workspace) do
        light.Enabled = bool
    end
end
0
where exactly do i put tihs in the script? ComplexitiesLife 10 — 8y
0
You replace the "setLights = function() ... end" with that. Also remember to mark this as the answer to your question and give rep. 0xDEADC0DE 310 — 8y
Ad

Answer this question