|
|
(29 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
| {{CatUp|:Category:Functions}}
| | #REDIRECT [[Clone_(Method)]] |
| | |
| 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
| |
| |arguments =
| |
| |returns = [[Instance]] object
| |
| |description = Returns a copy of this Object and all its children. The copy's Parent is nil
| |
| |object = Global
| |
| |}}
| |
| </onlyinclude>
| |
| | |
| ==Example 1==
| |
| | |
| This example creates a copy of a car every 5 minutes, and gives the new car a silly name.
| |
| <pre>
| |
| while true do --Starts up a While loop
| |
| | |
| model = game.Workspace.Car:Clone() --This line creates a copy of "Car" in the Workspace.
| |
| --Since we set it to "model" we can do things with it.
| |
| | |
| model.Name = "LOLZCARLOLOLOLOL" --Here we set the name of the Model to something silly.
| |
| --But the model is just a variable, not an object.
| |
| --For that we need to set it's parent.
| |
| | |
| model.Parent = game.Workspace --Now we make it appear in the game world.
| |
| | |
| wait(300) --Wait 300 seconds, or about 5 minutes.
| |
| | |
| end
| |
| </pre>
| |
| | |
| ==Example 2==
| |
| | |
| This example simply creates an instant copy of the original model.
| |
| <pre>
| |
| game.Workspace.Model:Clone.Parent = game.Workspace
| |
| </pre>
| |