So, if i have this part, how can i duplicate it a random amount of times? I was thinking of something like this: (using in pairs loop)
local randomnumber = math.random(1,9) -- number between 1 and 9 for i,v in pairs --duplicate item (randomnumber) amount of times --im writing on mobile end
Here is the code, I will explain after:
local item = your item local randomnumber = math.random(1, 9) for i = 1, randomnumber do item:Clone() end
What this does, is it creates a random number and then does a loop that number of times. Every time it goes through the for
loop, it adds 1 to i
. The loop will break, or stop when i
reaches randomnumber
. You can additionally set the position, or whatever of each part like this:
local item = your item local randomnumber = math.random(1, 9) for i = 1, randomnumber do local new = item:Clone() new.Position = Vector3.new(0, i, 0) -- this will create a sort of tower, with each part on top of each other end
Hope I helped!