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

Cloning models with a specific number of times possible?

can you like clone a model a number of times using Values and stuff?if so how?

2 answers

✓ Accepted answer

You could clone it multiple times, by creating multiple references to it and working with them separately or, by looping the the cloning action.

  1. References

both s and s1 are references to the same table

local s = {value = 'Scripting'}
local s1 = s

-- therefore
print(s.Value) --[[would return the same output as]] print(s1.Value) 

you could then create multiple references to the clone of a specified item.

NB: Changing the value of s will not change the value of s1

  1. Loops

You could also use a loop (while, repeat, generic for)

local my = workspace.Camera

for i = 1, 10 do
	my:clone()
end

You would of course have to take care of parenting your cloned items to appropriate places.

Resources: Loops

2 comments

1

thank you :D

0

yup

Yeah, you can do that using the for loop. The first argument (value) is a starting point, which is a variable assignment (in this case is going to be i to the number 1), the second argument is the end point (a simple answer is that the loop doesn't stop counting until the end point is reached.) So if you put in 1 and 3, it will activate three times. Use the code below:


for i = 1, 3 do -- Change three to how many times local newThing = thing:Clone() newThing.Parent = workspace -- Or wherever you want to parent it. -- An alternative version is thing:Clone().Parent = wherever, but I broke it down to help end


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