How would I clone all parts in a folder at the same time?
Instead of just this way -
local Ball1 = game.replicatedstorage.Balls.Ball1
local Ball2 = game.replicatedstorage.Balls.Ball2
local Ball3 = game.replicatedstorage.Balls.Bal3
while true do
Ball1:Clone
Ball2:Clone
Ball3:Clone
wait(1)
end
--i - index. v - value, the ball instance.
for i, v in pairs(game:GetServer('ReplicatedStorage').Balls:GetChildren()) do
v:Clone().Parent = workspace
end
One more thing I forgot to include. Is there any way to delete everything that was just cloned a few seconds after. So for example, parts get cloned and after 10 seconds those cloned parts get deleted. Thanks.
for i, v in pairs(game:GetService('ReplicatedStorage').Balls:GetChildren()) do
local c = v:Clone()
game.Debris:AddItem(c, 10) --'10' is current lifespan
c.Parent = workspace
end
One last thing I’m sorry. I tried adding while true do on top of this, but it gives me the error of timing out.
while true do
for i, v in pairs(game:GetService('ReplicatedStorage').Balls:GetChildren()) do
local c = v:Clone()
game.Debris:AddItem(c, 10) --'10' is current lifespan
c.Parent = workspace
end
end
while wait(1) do
for i, v in pairs(game:GetService('ReplicatedStorage').Balls:GetChildren()) do
local c = v:Clone()
game.Debris:AddItem(c, 10) --'10' is current lifespan
c.Parent = workspace
end
end
Right now your code is executing constantly without waiting which leads to it timing out.
while wait(10) do
for i, v in pairs(game:GetService('ReplicatedStorage').Balls:GetChildren()) do
local c = v:Clone()
game.Debris:AddItem(c, 10) --'10' is current lifespan
c.Parent = workspace
end
end