I want to fade in/out a group of bricks using a button (preferably using something like a loop). This is the script I have right now without the fade (basically turning it on):
model = game.Workspace.LIGHTS
function start ()
for _,v in pairs(model:GetChildren()) do
v.Transparency = .9
v.SpotLight.Enabled = true
v.PointLight.Enabled = true
end
script.Parent.ClickDetector.MouseClick:connect(start)
What I want to do is to have the Transparency and spotlight fade in using a loop. I know I could use this and it would basically do what I want:
model = game.Workspace.LIGHTS
function start ()
for _,v in pairs(model:GetChildren()) do
v.Transparency = .99
v.SpotLight.Enabled = true
v.PointLight.Enabled = true
wait(.001)
v.Transparency = .98
wait (.001)
v.Transparency = .97
wait (.001)
v.Transparency = .96
wait (.001)
v.Transparency = .95
v.SpotLight.Brightness = .5
wait (.001)
v.Transparency = .94
wait (.001)
v.Transparency = .93
wait (.001)
v.Transparency = .92
wait (.001)
v.Transparency = .91
wait (.001)
v.Transparency = .9
v.SpotLight.Brightness = 100
end
script.Parent.ClickDetector.MouseClick:connect(start)
The only problem with that is
- Its a mouthful of lines
- When it activates, it does one part of the model at the time while what I want is everything to work in sync.
If you don't understand the problem and need more clarification, let me know. Thanks!

2 comments
for i,v in pairs (obj:GetChildren()) do
and use for loops