Skip to content

IsObjectValid(handle)

The IsObjectValid function returns a boolean true or nil depending on whether the supplied argument is a valid object.

  • Handle:
    The argument should be the handle to a possible object.
  • Boolean or nil:
    The returned value is a boolean True if the handle is a valid object or it returns nil if it is not a valid object.

This example below examines if “Root()” is a valid object and prints meaningful feedback:

Copy CodeLua
```
return function()
--Create a variable with the possible object
local myObject = Root()
--Check if it is an object
local myReturn = IsObjectValid(myObject)
--Print the result
if myReturn == nil then
ErrPrintf("It is not a valid object")
else
Printf("It is an object")
end

end