Garry's Mod Wiki

Revision Difference

Global.IsValid#560013

<function name="IsValid" parent="Global" type="libraryfunc"> <description> Returns whether an object is valid or not. (Such as <page>Entity</page>s, <page>Panel</page>s, custom <page>table</page> objects and more). Checks that an object is not nil, has an IsValid method and if this method returns true. <note>Due to vehicles being technically valid the moment they're spawned, also use <page>Vehicle:IsValidVehicle</page> to make sure they're fully initialized</note>⤶ Returns whether an object is valid or not. (Such as <page text="entities">Entity</page>, <page>Panel</page>s, custom <page>table</page> objects and more). ⤶ Checks that an object is not <page>nil</page>, has an `IsValid` method and if this method returns `true`. If the object has no `IsValid` method, it will return `false`. <note>Due to vehicles being technically valid the moment they're spawned, also use <page>Vehicle:IsValidVehicle</page> to make sure they're fully initialized.</note>⤶ </description> <realm>Shared and Menu</realm> <file line="225-L234">lua/includes/util.lua</file> <args> <arg name="toBeValidated" type="any">The table or object to be validated.</arg> </args> <rets> <ret name="" type="boolean">True if the object is valid.</ret> </rets> </function>