Color pallet UI; is there a better way?

Hi all, me again.

Recently I’ve been creating a color choosing UI, but it’s very time consuming. Before I continue working on it, is there a better way to make this?

What I’ve currently got:

UI:

120+ lines of code just getting each color:


(No, I did not write them. I just made a script that printed the code)

Put all of the text button’s in a frame. Then when each of them is clicked you can just take the button’s background color3 and use it to change the color of another GUI.

local frame = --define frame with all the buttons

local FrameToChange =--define UI object here

for i, v in pairs(frame:GetChildren()) do
   if v:IsA("TextButton") then
      v.Activated:Connect(function()
        FrameToChange.BackgroundColor3 = v.BackgroundColor3
      end)
   end
end
2 Likes

That’s so much of a better way. I’m gonna wait for more reply’s to come in, but for now I’m marking this as solution. Thank you!

2 Likes

Put an attribute inside every frame color stating which color else you can get the background color etc it is and you can loop through all the colors by doing the following:

local Colors = script.Parent.Colors

for _, color in ipairs(Colors:GetChildren()) do
   print(color.Name, color.BackgroundColor3)
end
1 Like

This is also a great solution! Thank you for the help!