There's a lot of parts in this model and i want them all to do the transparency loops at the same time, but it seems to be only doing it 1 at a time?
for i,v in pairs(workspace.Model:GetDescendants()) do if v:IsA('BasePart') or v:IsA('Decal') then for i =1,10 do local num =0 repeat wait() num = num + 1 v.Transparency = v.Transparency + 0.1 until num == 9 local num =0 repeat wait() num = num + 1 v.Transparency = v.Transparency - 0.1 until num == 9 end v.Transparency = 1 end end end
(for i, v in pairs) -- this means that in pairs, it will transparent two at a time.
Use a different method like for list = 1, # do ..
local ModelContents = {workspace.Model:GetChildren()} for MC = 1, #ModelContents do if ModelContents[MC]:IsA('BasePart') or ModelContents[MC]:IsA('Decal') then ModelContents[MC].Transparency = 0.5 -- code end end
-- Example part1 = script.Parent.p1 part2 = script.Parent.p2 part3 = script.Parent.p3 while true do for i = 1,10 do part1.Transparency = part1.Transparency + 0.1 part2.Transparency = part2.Transparency + 0.1 part3.Transparency = part3.Transparency + 0.1 wait(1) end for i = 1,10 do part1.Transparency = part1.Transparency - 0.1 part2.Transparency = part2.Transparency - 0.1 part3.Transparency = part3.Transparency - 0.1 wait(1) end end
Use a function called spawn()
to run the code in a new thread.
for i,v in pairs(workspace.Model:GetDescendants()) do if v:IsA('BasePart') or v:IsA('Decal') then spawn(function() for i =1,10 do local num =0 repeat wait() num = num + 1 v.Transparency = v.Transparency + 0.1 until num == 9 local num =0 repeat wait() num = num + 1 v.Transparency = v.Transparency - 0.1 until num == 9 end v.Transparency = 1 end) end end