Determine if a color is green white grey brown or sand

I want to determine that if le color is a green color white color grey color brown color or sand color now here is what I mean
Lets say we have a color
123,255,123
It looks like this
image
now I wanna determine that IF it is a green color or another color
another color
200,255,123
now I want the script to say that YES it is the color green in simpler words I want a script that ROUNDS the color aka what I just explained
if not possible then I just want a script that like changes the material of a part in a way that if the parts size is big it will change to Sand if small glass if medium Metal like dat can someone help me in that then?

2 Likes

You should make it so if the r and g are higher than b it’s yellow and so on. But the easiest way to do this is by making a part then change the part color to Color3 you want then get the new brick color

1 Like

Hmm, that’s a really interesting problem! I don’t think there’s a single scientifically “correct” way of doing this, human vision is really complex and on top of that color names and perceptions are hugely influenced by culture.

One solution would be to assign color names to certain RGB values in the color spectrum. To find the name of a given RGB value then, it’s just a matter of finding the closest named color in the spectrum:

In the illustration the white circles represent named colors, and the X is the RGB value of a color you want to find the name of. In that case it’s somewhere between E and F, but F is slightly closer so it’s just called whatever F is called. A dark-ish cyan perhaps?

Although you’d have to assign 3D coordinates to each color name, to get the full color spectrum. Notice there’s no white in the illustration

1 Like

Anyway, why do you need this? There might be an easier way to do it

If you are talking about a part you can do it with a brikcolor or if it is an image with a colour3, for example.

if script.parent.BrickColor == "255,255,255" then
      print("Yes is white")
else
      print("Not white")
end

or if it is an image

if script.parent.ImagenColor3 == "255,255,255" then
      print("Yes is white")
else
      print("Not white")
end

etc…

You can actually script where you can determine if a color is a certain one. Let’s say we want to determine if a BackgroundColor if it is white. Let input the following code:

if script.Parent.BackgroundColor3 == Color3.fromRGB(255,255,255) then
     print("white")
else
     print("not white")
end

So if it white, then it will print “white” else “not white” If you are trying to do it from a different color, then the format is RRR,GGG,BBB.

.parent is deprecated, opt to use .Parent instead.

i dont even want it to be equal i want it to be near

dont want it to be equal want it to be near

that solution is really genius tbh thank you

1 Like