Talk:Nil: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus
No edit summary
>Anaminus
No edit summary
(No difference)

Revision as of 20:31, 8 May 2008

Hey, we need to do a bit of cleanup on this article, ok? Also, I did some testing, and you can recover items deleted with :remove(), but :remove() makes the parent of all the item's children nil as well, so if you did recover the item, it would have no children that it previously had. Just setting the parent to nil, however, allows you to recover the object AND all of it's children, by resetting the parent. -- JustinP231 07:58, 8 May 2008 (CDT)

Setting the parent to nil doesn't necessarily delete the object. If the object is referenced, you have to set its parent to nil AND remove the reference from the variable refering to it, so it can be picked up by the garbagecollector:
p = Instance.new("Part")
p.Parent = workspace -- part is now a parent of workspace
p.Parent = nil -- part is now a parent of nothing
p.Parent = workspace -- part still exists because it is referenced by 'p'
p.Parent = nil
p = nil -- part is no longer referenced by anything, so it gets picked up by the garbagecollector
Anaminus 15:31, 8 May 2008 (CDT)