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 1) Its a mouthful of lines 2) 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!
We can use a loop to slowly increment it.
local Down = true while wait(0.01) do -- Dont want to kill roblox with this loop ok? if Down then -- if we are going down Part.Transparney = Part.Transparency - 0.01 else -- if we are going up Part.Transparency = Part.Transparency + 0.01 end if Part.Transparency == 0 then -- tell script to go up Down = false elseif Part.Transparency == 1 then -- tell script to go down Down = true end if Part.Transparency = 0.5 Spotlight.[NameOfPropertyHere] = 0.5 -- if you want to change every so often, or add it as part of the loop if you want it to change with. end end