04-02-2011, 11:16 PM
Wrong game.
[lua]
p = create("Box") -- Create a new box
p.Parent = game.World -- The part (a grey box, by default) has a parent, the world
sleep(1)
p.Parent = nil -- The part now has no parent (and so it disappears from view, but not from memory).
sleep(1)
p.Parent = game.World -- part still exists because it is referenced by the variable 'p'
sleep(1)
p.Parent = nil -- part disappears again (it has no parent)
p = nil -- part is no longer referenced by anything, so it gets picked up by the garbagecollector
[/lua]
[lua]
p = create("Box") -- Create a new box
p.Parent = game.World -- The part (a grey box, by default) has a parent, the world
sleep(1)
p.Parent = nil -- The part now has no parent (and so it disappears from view, but not from memory).
sleep(1)
p.Parent = game.World -- part still exists because it is referenced by the variable 'p'
sleep(1)
p.Parent = nil -- part disappears again (it has no parent)
p = nil -- part is no longer referenced by anything, so it gets picked up by the garbagecollector
[/lua]