local model = workspace.testgroup:GetChildren()
local trans = {}
wait(5)
for i,v in pairs(model) do
if v:IsA("BasePart") then
table.insert(trans,v)
end
end
for i,v in pairs(trans) do
for i = 0, 1, 0.25 do
wait(0.05)
v.Transparency = i
end
end
My bad, I forgot to further explain,
‘for i = 0, 10, 1 do’
The 10 can be increased to a bigger number so the fading time takes longer, of course you would have to change the ‘i / 10’ to the same middle number.
With TS, you can set the time of transition (I don’t know if that’s correctly written), ease direction and style (Bounce, Elastic, Linear, Etc.) And more!
In this case, you should follow this small example of where you should write the code:
for i,v in pairs(model) do
if v:IsA("BasePart") then
--Tween Code here.
end
end
Not sure if this would be a performace issue, but I’d make use of spawn() or coroutine to get the seamless transparency fade you’re looking for. This will run the fading function in a seperate thread without delaying looping through each part.
For example:
for i,v in pairs(model) do
if v:IsA("BasePart") then
spawn(function()
for i = 0, 1, 0.25 do
wait(0.05)
v.Transparency = i
end)
end
end
end
This way, you wouldn’t need to loop through the model twice and mess with tables or anything.
local Tween = game:GetService("TweenService")
local Info = TweenInfo.new(5) --how long it takes to fade
for __, P in pairs (testgroup:GetChildren()) do --make sure script is not in model
T = Tween:Create(P,Info,{Transparency = 0})
T:Play()
wait() --if you want delays between each part or remove if you want all to diaper at once
end
Not sure if this would solve the OP’s threading issue, but if it doesn’t make sure you wrap the contents of the loop in a coroutine or a spawn to multithread it.
I’m not sure if TweenService yields when you create and play a tween but this might be a better option on the performance end of things if it doesn’t.