Garry's Mod Wiki

Revision Difference

Entity:GetColor#515878

<function name="GetColor" parent="Entity" type="classfunc"> <description> Returns the color the entity is set to. <bug issue="2407">The returned color will not have the color metatable.</bug> </description> <realm>Shared</realm> <rets> <ret name="" type="table">The color of the entity as a <page>Color</page>.</ret> </rets> </function> ⤶ <example>⤶ <description></description>⤶ <code>⤶ for key, ply in pairs( player.GetAll( ) ) do -- Loop through all players on the server⤶ local col = ply:GetColor( ); -- Gets the players color and assigns it to local variable col ⤶ {{Example⤶ | Description = ⤶ | Code = for key, ply in pairs( player.GetAll( ) ) do -- Loop through all players on the server⤶ ```⤶ local col = ply:GetColor( ); -- Gets the players color and assigns it to local variable col print( "Printing " .. ply:Nick() .. "'s color!" ); -- Say we are printing the players name's color PrintTable( col ); -- Pass col into PrintTable to print to contents of col end⤶ </code>⤶ <output>Loop through all players, and print their color.</output>⤶ ⤶ </example>```⤶ ⤶ end⤶ | Output = Loop through all players, and print their color.}}