Create a hexagonal color pallete just like the one in studio. Customize position, size, and padding between cells.
Code
local function createBrickColorPallete(size: UDim2, pos: UDim2, parent: GuiObject, padding: Vector2?, onColorPressedCallback: ((Color3) -> ())?)
padding = padding or Vector2.one
local folder = Instance.new("Folder", parent:FindFirstAncestorWhichIsA("ScreenGui"))
folder.Name = "BrickColorPallete"
local frame = Instance.new("Frame", parent)
frame.BackgroundTransparency = 1
frame.AnchorPoint = Vector2.new(.5, .5)
frame.Size = size
frame.Position = pos
local sizeX, sizeY = frame.AbsoluteSize.X, frame.AbsoluteSize.Y
local midX, midY = frame.AbsolutePosition.X + sizeX/2, frame.AbsolutePosition.Y + sizeY/2
local cellSize = math.min((sizeX - 12*padding.X)/13, (sizeY - 12*padding.Y)/13)
local yPosToPalleteValue = {
[-6] = -1,
[-5] = 6,
[-4] = 14,
[-3] = 23,
[-2] = 33,
[-1] = 44,
[0] = 56,
[1] = 69,
[2] = 81,
[3] = 92,
[4] = 102,
[5] = 111,
[6] = 119,
}
local rowSize
local yPos = 0
for row = 1, 13 do
local offset = (row-1)*(row%2==0 and 1 or -1)
yPos = yPos + offset
rowSize = 13 - math.abs(yPos)
local column = 0
local xPos = 0
local isEven = rowSize%2 == 0
for column = 1, rowSize do
xPos = xPos + (column-1)*(column%2==0 and 1 or -1)
local modXPos = xPos-(isEven and .5 or 0)
local palleteValue = yPosToPalleteValue[yPos] + math.ceil(rowSize/2)+xPos
local color = Instance.new("TextButton", folder)
color.AnchorPoint = Vector2.new(.5, .5)
--color.Text = palleteValue
color.Text = ""
color.Size = UDim2.fromOffset(cellSize, cellSize)
color.Position = UDim2.fromOffset(midX + modXPos*cellSize + modXPos*padding.X, midY + yPos*cellSize + yPos*padding.Y)
color.BackgroundColor = BrickColor.palette(palleteValue)
color.MouseButton1Down:Connect(function()
onColorPressedCallback(color.BackgroundColor3)
end)
end
end
frame:Destroy()
end
task.wait(3)
createBrickColorPallete(UDim2.fromScale(1, 1), UDim2.fromScale(.1 , .5), game.Players.LocalPlayer.PlayerGui.f.Frame, Vector2.new(5, 5), function(color)
print(color, "pressed")
end)