Clone (Function): Difference between revisions

From Goodblox Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
{{CatUp|Functions}}
{{CatUp|Functions}}
 
{||<onlyinclude>
{|
|<onlyinclude>
{{Function|
{{Function|
name                  = Clone
name                  = Clone
Line 9: Line 7:
|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>
|}}</onlyinclude>|}
|}
 


==Example==
==Example==
<pre>
<pre>
while true do
while true do   --Starts up a While loop
     model = workspace.Model:Clone()
     local model = workspace.Model:Clone() --Right here, it creates a copy of workspace.Model, and sets it as the variable "model"
    model.Parent = workspace
      
     wait(300)
     workspace.Model:Remove() --This removes workspace.Model from the game.
end</pre>
   
==or==
    model.Parent = game.Workspace  --Sets the cloned object's Parent to the Workspace.
<pre>
   
while true do
     wait(300) --Waits for 300 seconds.
     workspace.Model:Clone().Parent = workspace
end
     wait(300)
</pre>
end</pre>
 
which does the same thing
 
== Limitations ==
Objects with [[Archivable (Property)|archivable]] set to false are not cloned.
 
These classes are known to be unclonable: [[GBX.lua.Hat (Object)|Hats]], [[Workspace]]


[[Category:Functions]]
[[Category:Functions]]

Revision as of 20:34, 23 September 2021

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


Example

while true do   --Starts up a While loop
     local model = workspace.Model:Clone()  --Right here, it creates a copy of workspace.Model, and sets it as the variable "model"
     
     workspace.Model:Remove()  --This removes workspace.Model from the game.
     
     model.Parent = game.Workspace  --Sets the cloned object's Parent to the Workspace.
     
     wait(300)  --Waits for 300 seconds.
end