Garry's Mod Wiki
Description
Returns whether the entity is a valid entity or not.
An entity is valid if:
- It is not a NULL entity
- It is not the worldspawn entity (game.GetWorld)
It will check whether the given variable contains an object (an Entity) or nothing at all for you. See examples.
This might be a cause for a lot of headache. Usually happening during networking etc., when completely valid entities suddenly become invalid on the client, but are never filtered with IsValid(). See GM:InitPostEntity for more details.
Returns
Example
Shows how to use the global IsValid function instead of using this method directly.
Example
Example
- A lua error telling us 'ImportantGameData' is a nil value and thus can't perform math on it
But this shouldn't be possible, because we just created a value there. No red flags are present up until this point; all code up until this will run fine. Make sure to add an IsValid() check when the seemingly impossible happens.
This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated four times a day. Edits and history are not available.
Last Parsed: Loading...