You don't need to know a list of all of the palette colors. Notice
script.Parent.Text == "White"
and you write
BrickColor.new("White")
Given the above equality, what's a way to rewrite the second expression so that it doesn't refer to a specific color?
BrickColor.new(script.Parent.Text)
In other words, to handle all colors, you can simply do
while wait(1) do
local color = BrickColor.new(script.Parent.Text)
pcb = game.Workspace.F1Standard.PrimaryColoredBlocks:GetChildren()
for _, part in pairs(pcb) do
if part:IsA("BasePart") then
part.BrickColor = color
end
end
end
This has a minor problem, which is that it will accept not real color names and default to gray.
You can check that the name of the resulting color matches to prevent this:
while wait(1) do
local color = BrickColor.new(script.Parent.Text)
if color.Name == script.Parent.Text then
pcb = game.Workspace.F1Standard.PrimaryColoredBlocks:GetChildren()
for _, part in pairs(pcb) do
if part:IsA("BasePart") then
part.BrickColor = color
end
end
end
end
1 comment
Umm, this is from 3 years ago. But thanks?