I’m trying to make an automatic day/night cycle with these torches so that at day time the torches are off but at night they are on.
The issue is that the script isn’t working at all and I have no idea what I did wrong.
I looked at tutorials that are similar to what I’m doing but they didn’t help me solve the problem.
![]()
![]()
![]()


local lighting = game:GetService("Lighting")
function Lights(boolvalue)
if boolvalue == true then
for i, v in pairs(script.Parent:GetDescendants()) do -- night
if v:IsA("PointLight") or v:IsA("Smoke") or v:IsA("ParticleEmitter") then
v.Enabled = true
elseif boolvalue == false then
for i, v in pairs(script.Parent:GetDescendants()) do -- day
if v:IsA("PointLight") or v:IsA("Smoke") or v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
end
end
end
end
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if lighting.ClockTime >= 18.5 or lighting.ClockTime <= 7 then -- night time
Lights(true)
elseif lighting.ClockTime >= 7 or lighting.ClockTime <= 18.5 then -- day time
Lights(false)
end
end)
