Hey!

I have been making a chance system for my shop but it’s not really working. By this I mean that I get super rare cards 90% of the time.

Script:

```
module.GetCard = function(pack)
local ChanceTable = {}
for i,v in pairs(pack) do
local chance = 0
if string.find(v, "S1") then
chance += prices.Prices["S1"]
elseif string.find(v, "S2") then
chance += prices.Prices["S2"]
elseif string.find(v, "S3") then
chance += prices.Prices["S3"]
elseif string.find(v, "S4") then
chance += prices.Prices["S4"]
elseif string.find(v, "S5") then
chance += prices.Prices["S5"]
end
table.insert(ChanceTable, {[v] = chance})
end
local Weight = 0
for _, Chance in pairs(ChanceTable) do
for _, value in pairs(Chance) do
Weight += (value * 10)
break
end
end
print(ChanceTable)
local ranNumber = math.random(1, Weight)
Weight = 0
for prize, chance in pairs(ChanceTable) do
for _, value in pairs(chance) do
Weight += (value * 10)
end
if Weight >= ranNumber then
for j,k in pairs(chance) do
return j
end
end
end
end
```

When I print chance table this is what is printed:

```
{
[1] = ▼ {
["Kainu S4"] = 160
},
[2] = ▼ {
["Blackmoustache S3"] = 80
},
[3] = ▼ {
["Taro S2"] = 40
},
[4] = ▼ {
["Loof S2"] = 40
},
[5] = ▼ {
["Diu S5"] = 320
}
}
```