Change Ui Backgroundcolor with the color name, for example: "really red"

Hey,
I wanted to make the cloned buttons Backgroundcolor to get changed by the colrs name like in “Brickcolor”.
Is there any way to do so?

local Colors = script.Colors:GetChildren()

for i = 1, #Colors do
	local Button = script.TextButton:Clone()
	Button.Name = Colors[i].Name
	Button.Text = Colors[i].Name
	Button.Parent = script.Parent
	Button.BackgroundColor3 = Colors[i].Name
end

I guess you could use the .new() constructor of BrickColor like so:

local Colors = script.Colors:GetChildren()

for i = 1, #Colors do
	local Button = script.TextButton:Clone()
	Button.Name = Colors[i].Name
	Button.Text = Colors[i].Name
	Button.Parent = script.Parent
	Button.BackgroundColor3 = BrickColor.new(Colors[i].Name)
end
1 Like

I already tried that, but it wants a color3 and not a string.
…invalid argument #3 (Color3 expected, got BrickColor)

Are the “Colors” parts? if they are then you could use part.Color.

1 Like

I finally figured it out.
It has to be: BrickColor.new(Colors[i].Name).Color
Thanks for helping anyway :smiley:

2 Likes

Oh yeah, completely missed out on UI objects using Color3, not BrickColor :sweat_smile: