|
| 20 Mar 2012 06:43 AM |
My first question is if I can clone more than once? Is this possible without a bunch of :Clone() lines?
My second is if I can actually insert those clones, (Or any object) into every object in a model. I was thinking this is how virus spreads work, but it has been a while since I've seen one. |
|
|
| Report Abuse |
|
|
vexStudio
|
  |
| Joined: 18 Mar 2012 |
| Total Posts: 55 |
|
|
| 20 Mar 2012 06:47 AM |
You could write out a bunch of lines cloning an object, but it would be much more efficient so simply use a numeric for loop.
for integer = 1, 10 do -- Alter. -- Code. end
{ Scripting level - intermediate. } |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2012 06:52 AM |
So, like...
For integer = 1,10 do integer = e:Clone() -- Assuming e exists end
Like that?
What about the second question? |
|
|
| Report Abuse |
|
|
vexStudio
|
  |
| Joined: 18 Mar 2012 |
| Total Posts: 55 |
|
|
| 20 Mar 2012 06:56 AM |
for integer = 1, 10 do local clone = e:Clone() -- Assuming 'e' exists. clone.Parent = "something" -- Alter the parent. end
As for your second question, yes, it is possible, but you would need to create a function that gets everything (children and descendants) of a service.
{ Scripting level - intermediate. } |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2012 07:01 AM |
| Thanks! I love you guys :) |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 20 Mar 2012 08:58 AM |
Cloning and parenting to each child of a model.
Let's assume that this model is a model named 'Chl' in Workspace.
e = --[[ path here, remove notations. ]] for _,v in pairs(Workspace.Chl:children()) do if v:IsA("BasePart") then --Checks to see if current object in the model is a part, wedge, seat, or other variation. e:Clone().Parent = v end end
|
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 20 Mar 2012 09:02 AM |
And of course, I didn't think of multiple models.
e = --[[ path here ]]
function clto(clne,mod) for _,v in pairs(mod:Clone()) do if v:IsA("Model") then clto(clne,v) elseif v:IsA("BasePart") then clne:Clone().Parent = v end end end
Then we just need to call the function. Assuming 'e' is the object you want to clone, and let's say that Model 'asd' in Workspace is the model you'd like to clone the object to...And let's say that you want the object to be cloned into every Part, Wedge, etcetera, but not Script, Fire, Sparkles, etcetera, then..
clto(e,Workspace.asd) |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2012 09:10 AM |
@Grimm considering the guy ask for this kind of help , dont you think it would be a bit More Friendly to make that Script Less Compact? Like easier to read.. Unfair for him
(unless you figured out what it mean ) |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 20 Mar 2012 01:49 PM |
I suppose I could explain it.. o:
e = --[[ path here ]]
function clto(clne,mod) for _,v in pairs(mod:Clone()) do if v:IsA("Model") then clto(clne,v) elseif v:IsA("BasePart") then clne:Clone().Parent = v end end end
'e' is a variable. It will serve as the object you would like to clone.
A function can be called using its name and the arguments to match its parameters. (What is inside the parenthesis)
What this does is loop through the second argument, which will be called variable 'mod'. 'v' is the item in the model we're currently at. '_' is the index we're at. We won't be using it, however.
If the item we're on is a Model (:IsA() is a method that checks if the item is what is the argument. You can use ClassNames or, like I did, BasePart, which is a grouping of different ClassNames.), then we will call the same function with the model inside the original as the model we will search. If it is not a model, and it is a BasePart (has the ClassName property as a Part, CornerWedgePart, FormFactorPart, ParallelRampPart, PrismPart, PyramidPart, RightAngleRampPart, SkateboardPlatform, SpawnLocation, TrussPart, VehicleSeat, or Seat [I think that's all of them..?]), then we will clone 'e' and place it inside of the object we were on, in the loop. |
|
|
| Report Abuse |
|
|