I’m having an issue.
I optimized my code from 300-500 lines to 61 lines.
One problem, during the loop, each thing repeats after a different one is activated.
In this case: https://gyazo.com/be0c3ec7fcd4569b59b0ea40634dd768
This is a VERY buggy Fade In Effect which is caused by the optimized code. I can’t find any errors that create that buggy effect. At the end of that GIF, I quickly showed the Fade Out effect (which is an example of HOW it should fade).
Here’s my optimized code.
function Fade_In(v)
v.Head.Lens.Transparency = _G.EFFECT_DIMMER
v.Head.Beam.light.Transparency = NumberSequence.new(_G.EFFECT_DIMMER)
v.Head.Beam.SpotLight.Brightness = _G.EFFECT_DIMMER
wait(.01)
v.Head.Beam.SpotLight.Brightness = 5
v.Head.Lens.Transparency = .5
v.Head.Beam.light.Transparency = NumberSequence.new(.5)
wait(.01)
v.Head.Beam.SpotLight.Brightness = 7.5
v.Head.Lens.Transparency = .25
v.Head.Beam.light.Transparency = NumberSequence.new(.25)
wait(.01)
v.Head.Beam.SpotLight.Brightness = 10
v.Head.Lens.Transparency = 0
v.Head.Beam.light.Transparency = NumberSequence.new(0)
end
function Fade_Out(v)
v.Head.Beam.SpotLight.Brightness = 10
v.Head.Lens.Transparency = 0
v.Head.Beam.light.Transparency = NumberSequence.new(0)
wait(.01)
v.Head.Beam.SpotLight.Brightness = 7.5
v.Head.Lens.Transparency = .25
v.Head.Beam.light.Transparency = NumberSequence.new(.25)
wait(.01)
v.Head.Beam.SpotLight.Brightness = 5
v.Head.Lens.Transparency = .5
v.Head.Beam.light.Transparency = NumberSequence.new(.5)
wait(.01)
v.Head.Lens.Transparency = _G.EFFECT_DIMMER
v.Head.Beam.light.Transparency = NumberSequence.new(_G.EFFECT_DIMMER)
v.Head.Beam.SpotLight.Brightness = _G.EFFECT_DIMMER
end
while wait(0.1) do for i,v in pairs(game:GetService("Workspace").TaLights:GetChildren()) do spawn(function()
if v.Name == "Ta1" or v.Name == "Ta24" then Fade_In(v) end wait(0.01)
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_In(v) end wait(0.01)
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_In(v) end wait(0.01)
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_In(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end wait(0.01)
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_In(v) end wait(0.01)
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_In(v) end wait(0.01)
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_In(v) end wait(0.01)
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_In(v) end wait(0.01)
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_In(v) end wait(0.01)
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_In(v) end wait(0.01)
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_In(v) end wait(0.01)
if v.Name == "Ta1" or v.Name == "Ta24" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_Out(v) end wait(0.01)
end) end end
Function Fade_Out is not the actual Fade Out effect I showed at the end of the GIF, I only called it like that because at the end of the FadeIn Sequence (which is a Fade Turn On), then FadeOut Sequence (which turn them OFF in a fade way), will be activated.
Help will be VERY appreciated.
(I don’t have my old code but trust me, you don’t want to see that disaster. It has the same functions as this but just shortened down to 61 lines.)
while true do wait(0.1) local light = game.workspace.TaLights:GetChildren()
for i = 1, #light do wait()
local v = light[i]
if v.Name == "Ta1" or v.Name == "Ta24" then Fade_In(v) end wait(0.01)
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_In(v) end wait(0.01)
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_In(v) end wait(0.01)
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_In(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end wait(0.01)
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_In(v) end wait(0.01)
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_In(v) end wait(0.01)
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_In(v) end wait(0.01)
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_In(v) end wait(0.01)
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_In(v) end wait(0.01)
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_In(v) end wait(0.01)
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_In(v) end wait(0.01)
if v.Name == "Ta1" or v.Name == "Ta24" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_Out(v) end wait(0.01)
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_Out(v) end wait(0.01)
end end end
Local cooldown = true
while true do wait(0.5) if cooldown == true then cooldown = false
local light = game.workspace.TaLights:GetChildren()
for i = 1, #light do wait()
local v = light[i]
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_In(v) end
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_In(v) end
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_In(v) end
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_In(v) end
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_In(v) end
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_In(v) end
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_In(v) end
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_In(v) end
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_In(v) end
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_In(v) end
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_In(v) end
if v.Name == "Ta1" or v.Name == "Ta24" then Fade_Out(v) end
if v.Name == "Ta2" or v.Name == "Ta23" then Fade_Out(v) end
if v.Name == "Ta3" or v.Name == "Ta22" then Fade_Out(v) end
if v.Name == "Ta4" or v.Name == "Ta21" then Fade_Out(v) end
if v.Name == "Ta5" or v.Name == "Ta20" then Fade_Out(v) end
if v.Name == "Ta6" or v.Name == "Ta19" then Fade_Out(v) end
if v.Name == "Ta7" or v.Name == "Ta18" then Fade_Out(v) end
if v.Name == "Ta8" or v.Name == "Ta17" then Fade_Out(v) end
if v.Name == "Ta9" or v.Name == "Ta16" then Fade_Out(v) end
if v.Name == "Ta10" or v.Name == "Ta15" then Fade_Out(v) end
if v.Name == "Ta11" or v.Name == "Ta14" then Fade_Out(v) end
if v.Name == "Ta12" or v.Name == "Ta13" then Fade_Out(v) end
end
cooldown = true
end end