Garry's Mod Wiki

Concepts - NULL Entity

NULL Entity

NULL is an error value specific to Garry's Mod lua that represents an invalid Entity.

Unlike nil, which has no data type, NULL is an Entity and has the functions of an Entity defined on it.
If called, functions on NULL will either return error values or throw an error message.
These functions exist primarily to provide more meaningful error messages to the user and developer.

See also nil


In this example, we'll examine some of the behavior of NULL

print( NULL == NULL ) -- true print( NULL == nil ) -- false print( isentity( NULL ) ) -- true print( NULL.GetPos ) -- function: 0x81991d7a (Or something similar) print( NULL:GetPos() ) -- [ERROR] XXX:XX: Tried to use a NULL entity! (Or something similar)