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

How do i set how much Instance i want Instance.new to generate?

So for example Lets say I did Instance.new('Part') But i wanted it to do it 100 times what would I have to do is there a parameter? also this has to be done instantly not with a loop

1 comment

0

I don't think that exist, you could just Clone() it 10 times tho.

2 answers

You can't set instance count, but you can create a lot of instances in couple of lines using "for loop".

For example:

local CountOfInstances = 10 -- this is the count, how much instances you will  create

for i = 1,CountOfInstances do
	local Part = Instance.new("Part")
	Part.Parent = workspace
	Part.Name = "Part_".. i
	wait()
end

P.S.

Sorry for my bad English ;p

Unfortunately unless you want to write 100 separate lines for each part using:

local part00 = Instance.new("Part")
local part01 = Instance.new("Part")
-- etc.

then the most efficient way to do this is a for-loop, which you can set without a wait-time (though this isn't recommended) which can be used to generate the exact same part 100 times:

for i = 1, 100, 1 do
	local part = Instance.new("Part")
	part.Parent = workspace
end

The above loop has parameters set as the (starting number, ending number, increment)

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