Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I do this for more then one part in the same script?

I have tried a few different ways with no success. This works fine for one part I just don't know the right way to do it for more parts. I am trying to it for ten different parts. Any direction I can be pointed in would be great. Thanks

local part = script.Parent.Part1
local copyPart = part:clone()

while true do
	part.AncestryChanged:wait()
	wait(60 * 2)
	part = copyPart:clone()
	part.Parent = script.Parent
end

1 answer

You can use a for statement!

local part = script.Parent:GetChildren() -- change this to the part locations, but keep :GetChildren() because it is needed.
local copypart = part:Clone()

for i, v in pairs(part) do
	v.AncestryChanged:wait()
	wait(120)
	v:Clone() -- i changed this because i thought it might work doing it this way, but change it if needed
	v.Parent = script.Parent
end
end

3 comments

0

I was trying it with prints in place so I can see whats happening and I noticed its only get one of the ten parts on the first print shouldn't it print all ten part names? local part = script.Parent:GetChildren() for i, v in pairs(part) do print(v.Name, "1") v.AncestryChanged:wait() print(v.Name, "2") wait(5) v:clone() v.Parent = script.Parent end

0

am I crazy or would that spend over 120 second on each part?

0

You would just do print(v.Name). And I think it would wait 120 seconds, but I'm just going off this guys script.

This discussion is preserved as it was. New answers, comments, and votes are closed.