hello, i have a luck system in a server script in serverscriptservice and its in a function, but everytime the function is called, it returns 1 more value (1st time = 1 value, 2nd time = 2 values etc). here is the function and where its called: (auradatamodule is a module script in replicatedstorage which has tables)
local function ChooseAura(auras)
local totalentries = 0
local adjustedentries = {}
for _, aura in pairs(auras) do
local adjustedchance = aura.Chance ^ (1 / luck)
table.insert(adjustedentries, 1 / adjustedchance)
totalentries += 1 / adjustedchance
end
local randomentry = math.random() * totalentries
local cumulativeentry = 0
for index, aura in pairs(auras) do
cumulativeentry += adjustedentries[index]
if randomentry <= cumulativeentry then
return aura
end
end
end
where its called:
local selectedaura = ChooseAura(auradatamodule.Auras)