When I put the rgb color after the color name it print nil for some reason, i don’t know why. Could someone help me with this?
local colorModule = {}
colorModule.colors = {
["Exotic"] = {
"Yoda",
},
["Legendary"] = {
"Gold",
"Silver",
"",
"",
"",
},
["Epic"] = {
"Violet",
"Terqoise",
"Beige",
"",
"",
},
["Rare"] = {
"Yellow",
"Red",
"Green",
"Orange",
},
["Uncommon"] = {
"Brown",
"Blue",
"Purple",
},
["Common"] = {
["White"] = Color3.fromRGB(255,255,255),
["Grey"] = Color3.fromRGB(128,128,128),
["Black"] = Color3.fromRGB(0,0,0),
},
}
colorModule.rarities = {
["Exotic"] = 0.1,
["Legendary"] = 1,
["Epic"] = 6,
["Rare"] = 17.9,
["Uncommon"] = 30,
["Common"] = 45,
}
print(colorModule.colors.Common[1]) -- prints nil
colorModule.chooseRandomColor = function(luck)
local randomNumber = math.floor(1+(1000-1)*math.random()^luck)
local counter = 0
for rarity, weight in pairs(colorModule.rarities) do
counter += weight * 10
if randomNumber <= counter then
local rarityTable = colorModule.colors[rarity]
local chosenColor = rarityTable[math.random(1,#rarityTable)] -- Error: ReplicatedStorage.ColorModule:63: invalid argument #2 to 'random' (interval is empty)
return chosenColor
end
end
end
colorModule.getChance = function(color)
local rarity
for i,v in colorModule.colors do
if v[color] then
rarity = v
end
end
local chance = colorModule.rarities[rarity] / #colorModule.colors[rarity]
end
return colorModule