I am trying to make a luck system where if the player rolls a certain chance, they get a stat in return
The issue is that the chances are not adding up to what they should be, for example, the 1/10 chance looks like a 1/100 chance, and I cant even obtain a 1/50 chance. I did a trial rolling the rune 1000 times, and these are my results
Ive tried looking for solutions on devforum, but couldn’t find any that really suit my needs.
This is my script:
local x = require(game.ReplicatedStorage.EternityNum) -- To use the bignum.
local config = script.Parent.config
script.Parent.part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local s = plr:FindFirstChild("Stats")
local money = plr.Stats:FindFirstChild("Money")
local multi = plr.Stats:FindFirstChild("Multi")
local comm = plr.Stats:FindFirstChild("Common")
local uncomm = plr.Stats:FindFirstChild("Uncommon")
local rare = plr.Stats:FindFirstChild("Rare")
local leg = plr.Stats:FindFirstChild("Epic")
local cele = plr.Stats:FindFirstChild("Legendary")
local mvp = plr.Stats:FindFirstChild("MVP")
local rg = plr.Stats:FindFirstChild("RuneMaster")
local ro = plr.Stats:FindFirstChild("RunesOpened")
local random1 = math.random(1,2) --50%
local random2 = math.random(1,5) --20%
local random3 = math.random(1,10) --10%
local random4 = math.random(1,50) --2%
local random5 = math.random(1,1000) --0.1%
if multi == nil then return false end
if x.meeq(x.convert(multi.Value),(x.convert(config.cost.Value))) then
local s = x.convert(multi.Value)
local v = x.convert(config.cost.Value)
s = x.sub(s,v)
multi.Value = x.bnumtostr(s)
if random1 == 2 then
local svb = x.convert(comm.Value)
local val =x.convert(config.amount.Value)
local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))
svb = x.add(svb, val)
comm.Value = x.bnumtostr(svb)
ro.Value = ro.Value + 1
if random2 == 5 then
local svb = x.convert(uncomm.Value)
local val = x.convert(config.amount.Value)
local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))
svb = x.add(svb, val)
uncomm.Value = x.bnumtostr(svb)
ro.Value = ro.Value + 1
if random3 == 10 then
local svb = x.convert(rare.Value)
local val = x.convert(config.amount.Value)
local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))
svb = x.add(svb, val)
rare.Value = x.bnumtostr(svb)
ro.Value = ro.Value + 1
if random4 == 50 then
local svb = x.convert(leg.Value)
local val = x.convert(config.amount.Value)
local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))
svb = x.add(svb, val)
leg.Value = x.bnumtostr(svb)
ro.Value = ro.Value + 1
if random5 == 1000 then
local svb = x.convert(cele.Value)
local val = x.convert(config.amount.Value)
local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))
svb = x.add(svb, val)
cele.Value = x.bnumtostr(svb)
ro.Value = ro.Value + 1
end
end
end
end
end
end
end
end
end)
local svb = x.convert(config.cost.Value)
local sv = x.convert(config.amount.Value)
script.Parent.part.BillboardGui.Cost.Text = "Req: "..x.short(svb).." Rebirths"-- just change the stuff between the ""
script.Parent.part.BillboardGui.Ammt.Text = x.short(sv).." Basic Rune "