Garry's Mod Wiki


  Entity ents.Create( string class )


Creates an entity. This function will fail and return NULL if the networked-edict limit is hit (around 8176), or the provided entity class doesn't exist.

Do not use before GM:InitPostEntity has been called, otherwise the server will crash! If you need to perform entity creation when the game starts, create a hook for GM:InitPostEntity and do it there.


1 string class
The classname of the entity to create.


1 Entity
The created entity, or NULL if failed.


Creates a gmod_button entity at Vector(0, 0, 0).

local button = ents.Create( "gmod_button" ) button:SetModel( "models/dav0r/buttons/button.mdl" ) button:SetPos( Vector( 0, 0, 0 ) ) button:Spawn()