Garry's Mod Wiki

Entity:SetColor

  Entity:SetColor( table color = Color(255, 255, 255, 255) )

Description

Sets the color of an entity.

Some entities may need a custom render mode set for transparency to work. See example 2.
Entities also must have a proper render group set for transparency to work.

When rendering a model manually via Entity:SetNoDraw inside ENTITY:Draw, you may need to use render.SetColorModulation in the render hook (where you call Entity:DrawModel) instead.

Arguments

1 table color = Color(255, 255, 255, 255)
The color to set. Uses the Color.

Example

Loop through all players, make them black

local colBlack = Color( 0, 0, 0, 255 ) -- Creates a black color for key, ply in player.Iterator() do -- Loop through all players on the server ply:SetColor(colBlack) -- Sets the players color to colBlack end

Example

Creates a wooden crate at 0,0,0 and turns it a transparent green

local ent = ents.Create("prop_physics") ent:SetPos(Vector(0,0,0)) ent:SetModel("models/props_junk/wood_crate001a.mdl") ent:Spawn() ent:SetColor( Color( 0, 255, 0, 230 ) ) ent:SetRenderMode( RENDERMODE_TRANSCOLOR ) -- You need to set the render mode on some entities in order for the color to change