Add a task.wait() so the lights don’t turn on all at the same time.
local lights = game.Workspace.lights
local Time = 1 -- seconds it takes to turn on the next light
for i, v in pairs(lights:GetDescendants()) do
if v:IsA("SurfaceLight") then
v.Enabled = true
end
task.wait(Time)
end
As for random order, use tables as suggested above.
Here’s how to implement the Fisher-Yates shuffle, lmk if you have any questions about understanding how the code works!
local function shuffleTable(t)
for i = #t, 2, -1 do
local j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
local lights = {}
for i, v in pairs(game.Workspace.lights:GetDescendants()) do
if v:IsA("SurfaceLight") then
table.insert(lights, v)
end
end
shuffleTable(lights)
for i, light in ipairs(lights) do
task.wait(1) -- however long you want
light.Enabled = true
end