Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get the name of the color from the Color3 Value?

Asked by 6 years ago

Title is self explanatory. Been trying to figure how to convert the Color3 Value to it's BrickName. I know there is a way of defining each code f.e:

local Color3Value = script:WaitForChild("ColorValue").Value
local BrickName = ""
if Color3Value.Value == Color3.new(0, 0, 0) then
BrickName = "Black"
elseif Color3Value.Value == Color3.new(255, 0, 0) then
BrickName = "Red"
---etc.
end

but I'm sure there is another, more efficient way.

1
I think you should use BrickColor.New(Color) XviperIink 428 — 6y
0
I don't think you're able to convert them sadly, only the other way around...All I can think of is a huge elseif chain, but that's not very efficient. Pojoto 329 — 6y
0
You could set a part's colour and then use it's BrickColor as BrickName? I'm not sure what exactly what you mean Vulkarin 581 — 6y
0
BrickColor.new(brick color constructor here).Name, sadly doesn't work for color3 values User#19524 175 — 6y

1 answer

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

BrickColours can be constructed with Colour3's. It'll return the closest BrickColour to that Color3. http://wiki.roblox.com/index.php?title=BrickColor#BrickColor.new

You can convert it to a BrickColour, then get its name.

local Bc = BrickColor.new(Color3.fromRGB(255, 0, 0)).Name
print(Bc) -- Really red

local nextBC = BrickColor.new(Color3.fromRGB()).Name) -- Color3.fromRGB() defaults to Color3.fronRGB(0, 0, 0) if no arguments are specified.

print(nextBC) -- Really black
Ad

Answer this question