I am trying to run every light in a folder using a master script, but I am not getting any error, but it is not working.
Here is the code.
for _, light in pairs(LightsFolder:GetChildren()) do
local Light = light:WaitForChild("L")
while wait(1)do
if(game.Lighting.ClockTime > 6.3)and(game.Lighting.ClockTime < 17.3)then
Light.PointLight.Enabled = false
Light.Material = ("Glass")
else
Light.Material = ("Neon")
Light.PointLight.Enabled = true
end
end
end
That is because you are stuck on a while loop on the first for loop, so the for loop doesn’t actually advance. This is why you’ll need to use spawn()
for _, light in pairs(LightsFolder:GetChildren()) do
task.spawn(function()
local Light = light:WaitForChild("L")
while task.wait(1) do
if(game.Lighting.ClockTime > 6.3)and(game.Lighting.ClockTime < 17.3)then
Light.PointLight.Enabled = false
Light.Material = ("Glass")
else
Light.Material = ("Neon")
Light.PointLight.Enabled = true
end
end
end)
end