How to get value of value in table

I want to get value of a value in a table, for example here is my table:

local rarityColors = {
	["Common"] = Color3.fromRGB(255, 185, 124),
	["Rare"] = Color3.fromRGB(98, 255, 90),
	["Epic"] = Color3.fromRGB(162, 55, 255),
	["Mythic"] = Color3.fromRGB(255, 52, 55),
	["Legendary"] = Color3.fromRGB(252, 255, 67)
}

I want to type name of rarity in table and get value of value in table.
something like:

local color = table.find(rarityColors,rarityName)

How can i accomplish that? :thinking:

Better to say dictionary then value of value in table. Anyways do:

local rarityColors = {
	["Common"] = Color3.fromRGB(255, 185, 124),
	["Rare"] = Color3.fromRGB(98, 255, 90),
	["Epic"] = Color3.fromRGB(162, 55, 255),
	["Mythic"] = Color3.fromRGB(255, 52, 55),
	["Legendary"] = Color3.fromRGB(252, 255, 67)
}
rarityColors["Common"] -- Would return the color value for common.
2 Likes

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