Garry's Mod Wiki

ClientsideModel

  CSEnt or nil ClientsideModel( string model, number renderGroup = RENDERGROUP_OTHER )

Description

Creates a non physical entity that only exists on the client. See also ents.CreateClientProp.

Parented clientside models will become detached if the parent entity leaves the PVS. A workaround is available on the issue tracker page linked below.

Issue Tracker: 861
Clientside entities are not garbage-collected, thus you must store a reference to the object (in a variable) and call CSEnt:Remove manually when necessary.

Issue Tracker: 1387
Clientside models will occasionally delete themselves during high server lag.

Issue Tracker: 3184

Arguments

1 string model
The file path to the model.
2 number renderGroup = RENDERGROUP_OTHER
The render group of the entity for the clientside leaf system, see RENDERGROUP enum.

Returns

1 CSEnt or nil
Created client-side model (C_BaseFlex) or nil if creation of the entity failed for any reason.

Example

Creates a clientside entity where the player is looking.

concommand.Add( "test_csent", function( ply ) local trace = ply:GetEyeTrace() local entity = ClientsideModel( "models/props_c17/oildrum001_explosive.mdl" ) entity:SetPos( trace.HitPos + trace.HitNormal * 24 ) entity:Spawn() end )