Hello!
does anyone know how to add luck multiplier/boost in a chances system?
heres my module :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local units, crates, config = unpack(require(ReplicatedStorage.packages.units))
local Chances = {}
function Chances.getindexbychance(Table)
print(Table)
local TotalWeight = 0
for _, data in pairs(Table) do
if not data["rarity"] then continue end
local chance = config.rarity_chances[data.rarity]
if not chance then continue end
TotalWeight += chance
end
local RandomChance = Random.new():NextNumber(0)
local CurrentChance = 0
print(TotalWeight, RandomChance)
for index, data in pairs(Table) do
if not data["rarity"] then continue end
local chance = config.rarity_chances[data.rarity]
if not chance then continue end
CurrentChance += chance
if RandomChance <= CurrentChance then -- chance
return index
end
end
end
return Chances
tanks