Clone (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
No edit summary
>Mr Doom Bringer
Reverted edits by Mr Doom Bringer (Talk) to last version by Travisdep
Line 1: Line 1:
{{CatUp|:Category:Functions}}
{{Function|
 
The Clone function creates a duplicate of an object. The object's Parent property needs to be set, as it is nil to start.
<onlyinclude>{{Function|
name                  = Clone
name                  = Clone
|arguments            =  
|arguments            =  
Line 8: Line 5:
|description          = Returns a copy of this Object and all its children. The copy's Parent is nil
|description          = Returns a copy of this Object and all its children. The copy's Parent is nil
|object              = Global
|object              = Global
|}}</onlyinclude>
|}}


==Example 1==


This example creates a copy of a car every 5 minutes, and gives the new car a silly name.
==Example==
<pre>
<pre>
while true do                        --Starts up a While loop


  model = game.Workspace.Car:Clone() --This line creates a copy of "Car" in the Workspace.
while true do
                                    --Since we set it to "model" we can do things with it.
model = game.Workspace.Model:clone()
 
model.Parent = game.Workspace
  model.Name = "LOLZCARLOLOLOLOL"    --Here we set the name of the Model to something silly.
wait(300)
                                    --But the model is just a variable, not an object.
end</pre>
                                    --For that we need to set it's parent.
==or==
<pre>


  model.Parent = game.Workspace     --Now we make it appear in the game world.
while true do
mgame.Workspace.Model:Clone().Parent = game.Workspace
wait(300)
end</pre>


  wait(300)                          --Wait 300 seconds, or about 5 minutes.
which does the same thing...........
 
end
</pre>
 
==Example 2==
 
This example simply creates an instant copy of the original model.
<pre>
game.Workspace.Model:Clone.Parent = game.Workspace
</pre>

Revision as of 21:02, 22 April 2010

Clone( )
Returns Instance object
Description: Returns a copy of this Object and all its children. The copy's Parent is nil


Example


while true do
 model = game.Workspace.Model:clone()
 model.Parent = game.Workspace
 wait(300)
end

or


while true do
 mgame.Workspace.Model:Clone().Parent = game.Workspace
 wait(300)
end

which does the same thing...........