Tween Not working Like planed

I have tried to make a tween that when completed does a specific thing, but what happens is that it does not do what I want it to do, when I put Tween.Completed: Wait (), it just does not animate all the transparency of the parts directly, If not, wait for each one to become transparent, how do I avoid this?

example :

for i, v in pairs(workspace.Folder:GetChildren()) do
    if v:IsA("BasePart") then
   local tween = v:tweenblablabla
   tween:Play()
   tween.Completed:Wait()  -- it needs to wait for EVERY part to set transparency to 1,and not directly put them all at 1
   end
end
1 Like

What did you put as the TweenInfo and the goal?

local tweenService = game:GetService("TweenService")

for i, v in pairs(script.Parent:GetDescendants()) do
		if v:IsA("BasePart") then
			local tInfo = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
			local t = tweenService:Create(v, tInfo, {Transparency = 1})
			t:Play()
t.Completed:Wait()
		end
	end

Nothing?

Try adding prints to see where the issue is occurring, like so:

local TweenService = game:GetService("TweenService")
local PartTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear)

for i,v in pairs(script.Parent:GetDescendants()) do
    if v:IsA("BasePart") then
        local Tween = TweenService:Create(v,PartTweenInfo,{Transparency = 1})
        Tween:Play()
        print("Tween played")
        Tween.Completed:Wait()
        print("Completed")
    end
end

But, there are no errors?, i just want a explanation why the tween waits for every part to set the transparency to 1, i want it to do it directly, this occurs when i put the “Tween.Completed:Wait()”

Oh, if the code works and you’re just wondering why it pauses, it’s literally because you put Tween.Completed:Wait().

If you removed it and just had this:

local TweenService = game:GetService("TweenService")
local PartTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear)

for i,v in pairs(script.Parent:GetDescendants()) do
    if v:IsA("BasePart") then
        local Tween = TweenService:Create(v,PartTweenInfo,{Transparency = 1})
        Tween:Play()
    end
end

All of them should tween at the same time

Yes but, i still want to do a action when the tween is completed

local TweenService = game:GetService("TweenService")
local PartTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear)

local function AfterTween()
    -- your action here
end

for i,v in pairs(script.Parent:GetDescendants()) do
    if v:IsA("BasePart") then
        local Tween = TweenService:Create(v,PartTweenInfo,{Transparency = 1})
        Tween:Play()
        Tween.Completed:Connect(AfterTween)
    end
end

Or if you want to do something with each part after it ends:

local TweenService = game:GetService("TweenService")
local PartTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear)

for i,v in pairs(script.Parent:GetDescendants()) do
    if v:IsA("BasePart") then
        local Tween = TweenService:Create(v,PartTweenInfo,{Transparency = 1})
        Tween:Play()
        Tween.Completed:Connect(function()
            -- action here, use v as the part
        end)
    end
end