I’m trying to make a neon sign effect; so, flickering lights randomly, that sort of thing. It’s too many lights to have a script for each one.
I, v, in pairs, while it does in the end affect each of the lights, does it in a row. I’m looking for all the lights to go off at once, and then reoccur together.
The script below works, and it’s short and simple. It just makes all the lights turn off and on in a row; which isn’t what I’m looking for.
while true do
for i, v in ipairs(game.Workspace.FlickeringLights:GetChildren()) do
if v.Name == "Light" then
v.Material = Enum.Material.CorrodedMetal
wait(math.random(4,10)/10)
v.Material = Enum.Material.Neon
wait(math.random(4,10)/10)
end
end
end
Idk if it will help, but try cycling through them all before you wait, then cycle through them all again.
Get the wait’s out from in between the individual lights.
1 Like
something like this:
while true do
for i, v in ipairs(game.Workspace.FlickeringLights:GetChildren()) do
if v.Name == "Light" then
v.Material = Enum.Material.CorrodedMetal
end
end
wait(math.random(4,10)/10)
for i, v in ipairs(game.Workspace.FlickeringLights:GetChildren()) do
if v.Name == "Light" then
v.Material = Enum.Material.Neon
end
end
wait(math.random(4,10)/10)
end
2 Likes
Thanks, that seems to have fixed it!
1 Like
Yeah i didn’t have all the ‘if’ and ‘end’ in the right place, but i guess you got it sorted.
1 Like
You could put this script inside ReplicatedStorage and do something like this to clone that script into every light without having to manually insert it into every light, that’s pretty much one of the only options you have here.
for i, v (workspace.FlickeringLights:GetChildren()) do
game.ReplicatedStorage.FlickerScript:Clone().Parent = v
end
1 Like