Garry's Mod Wiki

Entity:SetColor

Entity:SetColor( table color = Color(255, 0, 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.

Arguments

1 table color = Color(255, 0, 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 pairs(player.GetAll()) 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

Page Links


Special Pages


Wikis

?

Render Time: 30ms

DB GetPage 2
Generate Html 5
SaveChanges (1) 8
Render Body 0
Render Sidebar 12