So I currently have a weighted system and I tried converting it into a ModuleScript.
The code looks like this
local weight = 0
for _, chance in pairs(chancesTable) do
weight += (chance * 10)
print("First Chance: "..chance)
print("First Weight: "..weight)
end
local runNumber = math.random(1, weight)
weight = 0
for prize, chance in pairs(chancesTable) do
weight += (chance * 10)
print("Module weight: "..weight.." Module Prize: "..prize.." runNumber: "..runNumber)
return prize, chance
end
weight = 0
And the Chances look like this. Im currently using the normal spin Chance.
Chances.spinChance = {
Nothing = 86.9;
Extra1Spin = 8.5;
Extra3Spin = 2.5;
Extra5Spin = 1.5;
Coins = .5;
Ugc = .1;
}
Chances.betterspinChance = {
Nothing = 74.5;
Extra1Spin = 16.5;
Extra3Spin = 5;
Extra5Spin = 3;
Coins = .8;
Ugc = .2;
}
return Chances
the print function on the Chances works perfectly on the first script but then the weight is always 15. i cant really explain it well since i dont understand weighted systems much. any help is appreciated