Palette
A fixed row of colour swatches.
The smallest palette#
main:Palette({
Text = "Trail colour",
Callback = function(colour)
trailColour = colour
end,
})Without Colors it uses a built-in set of eight.
My Script
v1.0
Trail colour
Building it up#
Choose the swatches:
main:Palette({
Text = "Trail colour",
Colors = {
Color3.fromRGB(232, 93, 93),
Color3.fromRGB(90, 209, 122),
Color3.fromRGB(74, 168, 240),
},
Default = 2, -- 1-based index into Colors
Callback = setTrailColour,
})Every option#
| Option | Type | Default | What it does |
|---|---|---|---|
Textreq | string | — | The label. |
Callback | function(Color3, number) | — | Called with the chosen colour and its 1-based index. |
Colors | Color3[] | — | The swatches to offer. Colours is accepted too. Entries that are not Color3 values are dropped. |
Default | number | Color3 | — | The starting swatch, as a 1-based index or as one of the colours in Colors. Defaults to 1. |
Description | string | — | A quieter second line. |
Icon | string | — | An icon shown before the label. |
Save | string | boolean | — | Persist the choice under this key. true derives one from the section and label. |
Tooltip | string | — | Shown while the pointer is over the control. |
Disabled | boolean | false | Refuses input and dims the control. |
DisabledReason | string | — | Shown as a tooltip while it is disabled. |
Colors or Colours
Both spellings work. The library reads Colors first and falls back to
Colours.
Methods#
| Method | Returns | What it does |
|---|---|---|
Get() | Color3, number | The selected colour and its index |
Set(value) | true, or false, reason | Selects a swatch and fires Callback |
Set takes a 1-based index, or a Color3 that is one of the swatches. A colour
that is not in Colors, and an index past the end of the list, both return
false and a reason.
local trail = main:Palette({ Text = "Trail colour", Colors = swatches })
local colour, index = trail:Get()
trail:Set(3)Palette or ColorPicker?#
Use a palette when the choices are a short fixed list, such as team colours or rarity tiers. Picking one is a single click, and the user can only land on a colour you supplied.
Use a ColorPicker when the user needs any colour in the spectrum. It opens a panel and takes a drag to set.
Both take Save. A palette stores the index it is showing; a colour picker
stores the red, green and blue channels.