while true do
local frames = script.Parent:GetDescendants()
for _, v in pairs(frames) do
if v:IsA("Frame") then
v.BackgroundColor3 = Color3.fromRGB(255, 68, 21)
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
local ColorChange1 = TweenService:Create(v, Info, {BackgroundTransparency = 0})
ColorChange1:Play()
wait(0.01)
end
end
end
My question is how would I repeat the loop before it is finished so the effect is more frequent? so far it only repeats once the effect reaches the last light at the top. Thanks for any help
You could put the for loop inside a function that is spawned every so often. How often does not depend on whether the last one has finished, then.
local function LightPatternStart()
for _, v in pairs(frames) do
--Rest of your original code
end
end
while true do
task.spawn(LightPatternStart)
wait(1) --Can be any number even if the for loops would normally overlap
end
How about changing the code like this?
added a spawn function
while true do
local frames = script.Parent:GetDescendants()
for _, v in pairs(frames) do
spawn(function()
if v:IsA("Frame") then
v.BackgroundColor3 = Color3.fromRGB(255, 68, 21)
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
local ColorChange1 = TweenService:Create(v, Info, {BackgroundTransparency = 0})
ColorChange1:Play()
wait(0.01)
end
end)
end
end
I guess you could turn all the lights on at the end of LightPatternStart, if you dont see them all go on, that means theres no extra time between tweens. Im not sure thats the issue though.
Okay my bad, your original reply seems to be the solution, however the effect only repeats once as a result of the code, and then goes back to how it was before.