Nil means zilch, nothing, nonexistent.

When working with variables, assigning nil to the variable, doesn't "destroy" the original value, per se, but rather replaces the original value. Also, when calling a non-existing value, you will get nil as well. Ex:

print(a) --Output: nil
local a = 0
print(a) --Output: 0
a = nil
print(a) --Output: nil

When you attempted to index "a" and print its value at first, you got nil because "a" was yet to defined. Also, when you made "a" nil, you replaced its previous value with nil, but you didn't "destroy" the previous value of 0- it's just that "a" is no longer 0.

When the following code is used,


an object and all of its descendants are parented to nil, essentially "deleting" them.

Objects that are parented to nil, can be retrieved if you have a reference to the object. Ex:

object.Parent = Workspace

The code above removes object and all of its children to nil, then returns object to the Workspace.

Be warned, that objects that are in nil are garbage collected to conserve memory, meaning that if you don't revive them, they really are gone forever.