Talk:Nil
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)
Testing
The scripts
game.Workspace.Player.Humanoid.Health = 0
game.Workspace.Player.Humanoid.Health = nil
p = Instance.new("Part") p.Parent = game.Workspace p.Parent = nil p.Parent = game.Workspace p.Parent = nil p = nil
work. That last one is REALLY worth doing... more than once.
MINDRAKER 07:12, 24 August 2008 (CDT)
Wow,
Nice scripts now I have reset script for when I get stuck! --Sindy 22:25, 16 September 2008 (CDT)sindy
Use of the {{type}} template
Hold on a second. nil, as used in this article, is a value, not a type. nil is a type which has only one possible value: nil. The {{type}} template is not appropriate here.
- Hm, it depends. Technically, they are the same. But.. you're right. Anyways, I was mainly trying it to see what it'd look like. And it looks nice. The thing is, the link links to this article and therefore is shown as bold and doesn't show as a link. 9 February 2012
- Yeah, it might be an idea to override the bold styling.