Tweens work only for 1 part not for all

I’m trying to make christmas lights work with tweens, but only 1 part works per function, i need to have all parts to work at the same time, i think its problem with wait()

local tween = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local all = script.Parent:GetChildren()

while true do
	for i,v in pairs(all) do
		if v.Name == "BlueL" then
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
		end
	end
	for i,v in pairs(all) do
		if v.Name == "PurpleL" then
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
		end
	end
	for i,v in pairs(all) do
		if v.Name == "YellowL" then
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
		end
	end
	for i,v in pairs(all) do
		if v.Name == "GreenL" then
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
		end
	end
	for i,v in pairs(all) do
		if v.Name == "RedL" then
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
			wait(1)
			tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
		end
	end
end

Here is an untested and probably a bit off concept approach …
I’ve organizing the script for simplify sake. What I’m looking to do here is target an entire folder.

local tween = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local lightsFolder = script.Parent

local colors = {
    BlueL = Color3.fromRGB(170, 0, 170),
    PurpleL = Color3.fromRGB(196, 40, 28),
    YellowL = Color3.fromRGB(9, 137, 207),
    GreenL = Color3.fromRGB(218, 133, 65),
    RedL = Color3.fromRGB(0, 255, 0)
}

while true do
    wait(1)
    for _, light in pairs(lightsFolder:GetChildren()) do
        local color = colors[light.Name]
        if color then
            tween:Create(light, tweeninfo, { Color = color }):Play()
        end
    end
end

More of a scratch script starting point to a working approach.

1 Like
local tween = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local all = script.Parent:GetChildren()

while true do
	for i,v in pairs(all) do
		if v.Name == "BlueL" then
			task.delay(1, function()
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
			end)
		elseif v.Name == "PurpleL" then
			task.delay(1, function()
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
			end)
		elseif v.Name == "YellowL" then
			task.delay(1, function()
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
			end)
		elseif v.Name == "GreenL" then
			task.delay(1, function()
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
			end)
		elseif v.Name == "RedL" then
			task.delay(1, function()
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(196, 40, 28)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(218, 133, 65)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(0, 255, 0)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(9, 137, 207)}):Play()
				task.wait(1)
				tween:Create(v, tweeninfo, {Color = Color3.fromRGB(170, 0, 170)}):Play()
			end)
		end
	end
	
	task.wait(5)
end

It works, but i don’t want randomized colors but for example how will work
1 red light: red to yellow
2 yellow light: yellow to green
3 green light: green to blue
I want this to work at the same time.