PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

Destroy

Sets the Instance/Parent property to nil, locks the Instance/Parent property, disconnects all connections, and calls Destroy on all children. This function is the correct way to dispose of objects that are no longer required. Disposing of unneeded objects is important, since unnecessary objects and connections in a place use up memory (this is called a memory leak) which can lead to serious performance issues over time.

Once an Instance has been destroyed by this method it cannot be reused because the Instance/Parent property is locked. To temporarily remove an object, set Instance/Parent|Parent it to nil instead. For example:

object.Parent = nil
wait(2)
object.Parent = workspace

To Destroy an object after a set amount of time, use Debris/AddItem.

Returns

Return Type Summary

Code Samples


Instance:Destroy