Garry's Mod Wiki

ClientsideModel

  CSEnt 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 its github page.

Issue Tracker: 861
Clientside entities are not garbage-collected, thus you must store a reference to the object and call CSEnt:Remove manually. To workaround this bug, you need to hold a reference (in a variable) to the entity and remove it 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
Created client-side model (C_BaseFlex).

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 )