Hello there I am scripting a case opening system. Somehow whenever the i,v loop goes through the table it will always not compare the random number with 4(epic) and 25(uncommon) thus making it impossible to get them.Any help is appreciated
script:
PurchaseTrail = function(plr,CaseName)
local Chances = require(game.ServerScriptService.ItemChances)
local Price = game.StarterGui.MainGui.ShopAsset.TrailShop.Frame:FindFirstChild(CaseName).Price
local Tokens = plr.PlayerValues.Tokens
local case = game.ReplicatedStorage.Trails:FindFirstChild(CaseName)
local returned =""
if Tokens.Value >= Price.Value then
local Table = Chances.NormalChances
local randomNumber = math.random(0,100)
local tab = {}
for i,v in pairs(Chances.Chances) do
print(randomNumber)
print(i)
print(randomNumber < i)
if randomNumber < i then do
local picked = v
local inv = plr.OwnedTitles
for i,v in pairs(case:GetChildren()) do
if v.Rarity.Value == picked then
table.insert(tab,v)
else
end
end
local pick = tab[math.random(1,#tab)]
local new = Instance.new("BoolValue")
new.Name = pick.Name
new.Parent = inv
local rarityItem = Instance.new("BoolValue")
rarityItem.Name = pick.Rarity.Value
rarityItem.Parent = new
Tokens.Value = Tokens.Value - Price.Value
print(pick)
return pick
end
end
end
end
end,
Table Script:
local module = {
Chances = {
[1] = "Legendary" ,
[4] = "Epic",
[10] = "Rare" ,
[25] = "Uncommon",
[101] = "Common"
}
}
return module