Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cloning models with a specific number of times possible?

Asked by 9 years ago

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

2 answers

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

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

2. 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

1
thank you :D Arnel050039 20 — 9y
0
yup ImageLabel 1541 — 9y
Ad
Log in to vote
0
Answered by
DevChris 235 Moderation Voter
9 years ago

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
  

Answer this question