Hello. So I'm trying to make a script that would make all the parts in a model visible for a quick second and then repeat after another 5 seconds (using GetChildren so I wouldn't have to address every single part with a line of code). The problem is that when the script runs, It only makes one part visible at a time. Is there a way I could make it so that all the parts inside the model do the same thing at the same time? Any help would be greatly appreciated.
local gold = game.Workspace.gold
for i, v in pairs(gold:GetChildren()) do
if v:IsA("Part") then
wait(1)
v.Transparency = 0
v.CanCollide = true
wait(5)
v.Transparency = 1
v.CanCollide = false
end
end

1 comment
Hi! For this case, you should use something called "coroutine". It's extremely useful for running multiple things at once. See https://developer.roblox.com/en-us/api-reference/lua-docs/coroutine for more information