Garry's Mod Wiki


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


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.


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


Loop through all players, make them black

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


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