Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this part tween script work with multiple parts?

I have added GetChildren so that it will do the following to all of the children but it's not working? Any fixes/explanations?

local TweenService = game:GetService("TweenService")

local part = script.Parent:GetChildren()

 

local Info = TweenInfo.new(

3, -- Length

Enum.EasingStyle.Elastic, -- Easing Style

Enum.EasingDirection.Out, -- Easing Direction

2, -- Times repeated

true, -- Reverse

0 -- Delay

)

 

local Goals =

{

Transparency = 0.5;

Size = Vector3.new(15,15,15);

}

 

local tween = TweenService:Create(part,Info,Goals)

 

tween:Play()

1 answer

✓ Accepted answer

Hey greybird700,

The issue with your script is that you are putting in a table as the argument for TweenService's :Create() function and that can't happen because you need a UserData Value, not an Array. So, there's an easy fix for this, all you have to do is just use a for each iteration for the Array like so:

local TweenService = game:GetService("TweenService")

local parts = script.Parent:GetChildren()



local Info = TweenInfo.new(

3, -- Length

Enum.EasingStyle.Elastic, -- Easing Style

Enum.EasingDirection.Out, -- Easing Direction

2, -- Times repeated

true, -- Reverse

0 -- Delay

)



local Goals =

{

Transparency = 0.5;

Size = Vector3.new(15,15,15);

}

-- For each iteration with the 'next' method. Roblox calls it a 'generic for loop'. --
for _,part in next, parts do
local tween = TweenService:Create(part,Info,Goals)

tween:Play()
end

for _,part in next, parts do
	part.Transparency = 1;
end
-- For each iteration with the 'next' method. Roblox calls it a 'generic for loop'. --

##Well, I hope I helped in one way or another and have a great day/night.

~~ KingLoneCat

2 comments

0

Thanks buddy!!!

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.