Blink light loop ∞

You’d want to use a different thread for each blink so using spawn or coroutine should work, adapted code from @zahra_y735

local lights = {}

for _,v in pairs(script.Parent:GetDescendants()) do
  if v.ClassName == "PointLight" or v.ClassName == "SpotLight" or v.ClassName == "SurfaceLight" then
    table.insert(lights, v)
  end
end

while true do
  coroutine.wrap(function()
for i = 1, #lights do
for c = 1, 0.1, -0.1 do
    lights[i].Brightness =c

end
task.wait(0.1)
for c = 0.1, 1, 0.1 do
    lights[i].Brightness =c

end
  end
end)

end

or

Very useful for running multiple lines of code in one script without interference

1 Like