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

How to create timed lighting?

Asked by 8 years ago

Hi

I'm trying to create a light that follows the game lighting. So the lights will switch on at a certain time and switch off at a certain time as well.

I tried it out but failed. Can someone help me out?

-- Variables -
light = script.Parent.SurfaceLight

-- Main --
wait()
while true do
    if ("18:00:00" <= game.Lighting.TimeOfDay <= "06:00:00") then
        light.Enabled = false
    else
        light.Enabled = true
    end
end

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

In my opinion the easiest way would be to do something along these lines:

local light = script.Parent.SurfaceLight;

while wait() do
    if game.Lighting.TimeOfDay >= "18:00:00" then
        light.Enabled = true;
    elseif game.Lighting.TimeOfDay >= "06:00:00" then
        light.Enabled = false;
    end;
end;

This pretty much just checks the time and sets the light accordingly ** Please note: This is assuming you are using a day night script and it will change when it hits these times **

I hope this helped. If it didn't feel free to ask more questions, or pm me and ask for help if you have any other questions.

Ad

Answer this question