Tweening transparency but using :getchildren

Hey! I have a group of pumpkins inside a folder.

local part = workspace.Pumpkins:GetChildren()

I’m using a line of code to get all the children inside this pumpkin folder.

 local TweenService = game:GetService("TweenService")

local part =   workspace.Pumpkins:GetChildren()
 

local info = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local tween = TweenService:Create(part.Union, info, {Transparency = 0})

tween:Play()

I’ve attempted it here but am aware I’ve probably made a rookie mistake.

image

Here is the model of the pumpkin inside the folder in workspace.

Any help/support is greatly appreciated! <3

You can achieve that by using iterators

local TweenService = game:GetService("TweenService")
local Pumpkins = workspace.Pumpkins:GetChildren()

local info = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

for _, model in pairs(Pumpkins) do
	if model:IsA("Model") then
		local tween = TweenService:Create(model.Union, info, {Transparency = 0})
		tween:Play()
	end
end
1 Like

Oh awesome, thank you! So basically, you just check if there is a model and then run the code from there?

When you use :GetChildren() it will grab all the objects and put them in a table stored in that variable, when you iterate through the table you can check if it meets specific requirements like if it’s a model or something else.

Here I’m just going through the table checking if the object is a model and making a tween for the union if it is.

The reason I’m checking if its a model is because if you mistakenly put something in there that is NOT a model it will error the script since it will also check that object which may not have the union in it.

1 Like