Hello, what I’m trying to do is simply explained, I have a model that has 100 base parts in it and I want to tween them all to become invisible, but I’m not quite sure how I’d do that. If anybody knows how and could tell me, that’d mean a lot to me
If the parts in the model are all within the “same level” of the model, meaning all of them are direct children of the model yes. But if you have parts nested inside parts, then use Model:GetDescendants, to get absolutely all parts in the model, and use :IsA("BasePart") to check if that descendant is a part before trying to tween it
That wont tween them, just make it transparent instantly not over time. But yeah, if tweening or lerping is too much resource-consuming, would be preferably to not use the tween and make it instantly
here’s the thing, I’m tinerking with a lightning module and I dislike how all the lightning gathers into one focal point, and I want to make the parts invisible before reaching that point
Then I would go with :GetDescendants(), specially cause there are none more instances as decals, attachments, etc. And just iterate all its descendants choosing the baseparts by IsA:(“BasePart”) and if it is, proceed with the tween
for i , parts in pairs(Group:GetChildren()) do
if parts:IsA("BasePart") then
Tween:Create(parts,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out) , {Transparency = 1}):Play()
end
end
???
I’m pretty new to scripting so this kind of stuff doesn’t make too much sense to me, sorry.
Yeah, basically thats right, you could implement a table to create and save all tweens before playing them, and then a loop to Play() the table of the tweens previously created, only if you wish ofc.
Probably, make sure that you are not creating over and over all the tweens, handle the creation of tweens once, and have them ready to be used when its time.
You could reduce the creation of the multiple TweenInfos on each iteration of the loop too.
This is not complete code, but could give you an idea:
local tableOfTweens = {}
local Info = TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
for i , parts in pairs(Model:GetDescendants()) do
if parts:IsA("BasePart") then
table.insert(tableOfTweens, Tween:Create(parts, Info , {Transparency = 1}))
end
end