Revision Difference
ents.Create#547149
<function name="Create" parent="ents" type="libraryfunc">
<description>
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.
<warning>Do not use before <page>GM:InitPostEntity</page> has been called, otherwise the server will crash!
If you need to perform entity creation when the game starts, create a hook for <page>GM:InitPostEntity</page> and do it there.</warning>
</description>
<realm>Server</realm>
<args>
<arg name="class" type="string">The classname of the entity to create.</arg>
</args>
<rets>
<ret name="" type="Entity">The created entity, or `NULL` if failed.</ret>
</rets>
</function>
<example>
<description>Creates a gmod_button entity near `Vector(0, 0, 0)`.</description>
<description>Creates a gmod_button entity at `Vector(0, 0, 0)`.</description>
<code>
local button = ents.Create( "gmod_button" )
button:SetModel( "models/dav0r/buttons/button.mdl" )
button:SetPos( Vector( 0, 0, 100 ) )
button:SetPos( Vector( 0, 0, 0 ) )
button:Spawn()
</code>
</example>