Garry's Mod Wiki

Entity:SetColor

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

Description

Sets the color of an entity.

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_TRANSALPHA ) -- You need to set the render mode on some entities in order for the color to change

Page Links


Special Pages


Wikis

?

Render Time: 32ms

Session 0
DB GetPage 2
Generate Html 7
SaveChanges 8
Render Body 0
Render Sidebar 12