So i have this script below, I have tried to add a system where there is a luck factor invloded so you can increase your chances, just like in games when you have like double luck poitions or double luck gamepasses e.g. Here is my code let me know if you know how to make it better and fix it
module.items = {
["Celestial"] = 0.001,
["Divine"] = 0.01,
["Godly"] = 0.05,
["Mythic"] = 0.1,
["Exotic"] = 1,
["Legendary"] = 2.5,
["Epic"] = 5,
["Rare"] = 10,
["Uncommon"] = 26.4,
["Common"] = 54.939
}
local function chooseRarityNew(Givenluck : IntValue)
local luck = Givenluck or 1
local counter = 0
for rarity, weight in pairs(module.items) do
counter += weight
end
local randNum = math.random(1, counter)
randNum = randNum / luck
for rarity, weight in pairs(module.items) do
if randNum <= counter then
return rarity
end
end
end```