String color code table?

How would I put a string and a color code in the same table slot like this:

["Black"] = Color3.fromRGB(0,0,0),
table1 = {Black = Color3.fromRGB(0,0,0), White = Color3.fromRGB(255,255,255)}
colors = {
    ["Black"] = Color3.fromRGB(0, 0, 0),
    ["White"] = Color3.fromRGB(255, 255, 255)
}

local blackColor = colors["Black"]
print(blackColor)

part.Color = colors["Black"] 

Roblox also has a few different built in tables (calls) like this.
part.BrickColor = BrickColor.Red() --basic ones
part.BrickColor = BrickColor.Linen() --from the Roblox color spread

that already works

you can put anything as a value in a dictionary

table1 = {
  black = Color3.fromRGB(0,0,0),
}

print(table1.black) -- prints the color black

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.