print("Starting Lighting Cycle...")
local isNight = false
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local clockTime = tostring(game.Lighting.ClockTime)
if clockTime:sub(1, 4) == "18.5" and not isNight then -- 18:30:00
isNight = true
print("Night cycle!")
lighting.Brightness = 0
lighting.OutdoorAmbient = Color3.fromRGB(116, 116, 116)
lighting.Ambient = Color3.fromRGB(156, 156, 156)
local ParkLighting = game.Workspace.Lighting.EntranceLighting:GetDescendants()
for i,v in pairs(ParkLighting) do
if v:IsA("SurfaceLight") then
v.Enabled = true
end
end
elseif clockTime:sub(1, 4) == "6.4" then-- 06:24:00
isNight = false
print("Day cycle!")
lighting.Brightness = 2
lighting.OutdoorAmbient = Color3.fromRGB(207, 207, 207)
lighting.Ambient = Color3.fromRGB(163, 163, 163)
local ParkLighting = game.Workspace.Lighting.EntranceLighting:GetDescendants()
for i,v in pairs(ParkLighting) do
if v:IsA("SurfaceLight") then
v.Enabled = false
end
end
end
end)```
-- The script is intended to, when it is a certain time of day, change the lighting to the on/off settings. It works great at the top, and turns the lights on - but the elseif part won't work at all, and the lights continue staying on. I have no errors, and this is a normal script located in Workspace. Thank you.
Because a string of length 4 (“clockTime:sub(1, 4)
”) will never be equal to a string of length 3 (6.4
)
1 Like