Can you clone an item using ":Clone()" of how many clones you want?

Can you do that without this method?

local clone = game.ServerStorage.Part:Clone()
clone.Parent = workspace

local clone = game.ServerStorage.Part:Clone()
clone.Parent = workspace

local clone = game.ServerStorage.Part:Clone()
clone.Parent = workspace

Or is there another method to do this?

1 Like

I meant to write

local clone1 =
local clone2 =
local clone3 =

You could do this to be more effective

for i = 1,3 do --replace 3 with however many clones you want
    local clone = game.ServerStorage.Part:Clone()
    clone.Parent = workspace
end
1 Like

As danny had said, you can use looping. I tend to use a function for my object cloning when it comes to something like your scenario. Then I can just iterate through each one and do as I please with them in an order I wish.

-- function:
local function batchclone(object: Instance, count: number?): {Instance}
	assert(typeof(object) == 'Instance' and not object.Archivable, 'Provided object is not an Instance or is not Archivable')
	local array = {}
	if typeof(count) == 'number' and count > 1 then
		for i = 1, count, 1 do
			table.insert(array, object:Clone())
		end
	else
		array[1] = object:Clone()
	end
	return array
end

-- usage:
local serverstorage = game:GetService("ServerStorage") :: ServerStorage

for _, part in pairs(batchclone(serverstorage:WaitForChild("Part"), 3)) do
    part.Parent = workspace
end

If you want to infinitely clone the part, a way you can do this is by creating a while loop.
For example:

while true do
	local clone = game.ServerStorage.Part:Clone()
	clone.Parent = workspace
end

And like what Danny said, you can create a for loop if you want to create a specific amount of parts.

While loop no yielding will exhaust script execution time

Forgot to mention that lol
I should’ve added a wait() script
Sorry!