How can i clone something multiple times?

so im trying to make a attack clone something x times.
i could just copy & paste this script, but i want it to be random.

	Bomb.Parent = workspace
	Bomb.Position = SpawnerPart
	BombClone.Velocity = Vector3.new(0,20,0)
1 Like

Run a loop.

for count = 1, 10 do
    -- Clone stuff here
end
1 Like

this could work but i want it to randomize once, it’s in a function so i can do, now that i think about yeah this won’t work

local BombAmount = math.random(3,10)
1 Like
local BombCount = math.random(3,10)
for i = 0, BombCount do
    -- Clone the bomb etc.
end

It should work and keep on going until your randomized bomb count has been reached
By declaring the random amount outside of the loop it is only calculated once.

If this code is in a function, make sure you’re calling the function once and not multiple times.

3 Likes