Garry's Mod Wiki

Color:ToHex

  string Color:ToHex( boolean = false )

Recently Added

This was recently added in version (2025.07.15). It might only be available on the Dev Branch right now.

Description

Converts a Color to its hexadecimal representation.

Arguments

1 boolean = false
Whether to forcibly omit the alpha channel from the output.

Returns

1 string
The hexadecimal representation of the color. (#RRGGBBAA)

If the alpha channel is 255, it will be omitted from the output (#RRGGBB)