Hey there, i need a help with my Rarity/Chance System
i want add a luck into my code
i tries to do it and it always fails
Here my Code:
local Rarities = {
{“Bronze”, 0.00006, 60},
{“Silver”, 0.00004, 40},
{“Golden”, 0.000005, 5},
{“Diamond”, 0.0000025, 2.5},
{“Emerald”, 0.0000018, 1.8},
{“Ruby”, 0.00000016, 1.6},
{“Amethyst”, 0.00000013, 1.3},
{“Opal”, 0.00000011, 1.1},
{“Super”, 0.000000096, 0.96},
{“Ultra”, 0.0000000078, 0.78},
{“Ultimate”, 0.0000000069, 0.69},
{“Impossible”, 0.000000006, 0.6},
{“Limitless”, 0.0000000049, 0.49},
{“Invincible”, 0.000000004, 0.4},
{“Divine”, 0.0000000037, 0.37},
{“Omega”, 0.0000000031, 0.31},
{“Extreme”, 0.0000000028, 0.28},
{“Hyper”, 0.0000000025, 0.25},
{“Godly”, 0.0000000021, 0.21},
{“Exotic”, 0.0000000018, 0.18},
{“Supreme”, 0.0000000016, 0.16},
{“Celestial”, 0.000000001, 0.1},
{“Ethernal”, 0.000000000009, 0.09},
{“Super Limitless”, 0.0000000000085, 0.085},
{“Unreal”, 0.0000000000079, 0.079},
{"???", 0.000000000007, 0.07},
}
module.getItem2 = function(Val, Debounce, Data)
if Val == “getRarity” then
if Debounce == false then
if Data ~= nil and Data:IsA(“Instance”) then
local RNG = math.random
local Counter = 0
for i, v in pairs(Rarities) do
Counter += Rarities[i][2]
end
local Chosen = RNG(0, Counter)
for i, v in pairs(Rarities) do
if Data:FindFirstChild("Luck") then
Counter += Rarities[i][2] * Data:WaitForChild("Luck").Value
else
Counter += Rarities[i][2]
end
if Chosen <= Counter then
if Rarities[i] ~= nil then
return Rarities[i]
else
return {"Bronze", 0.00006, 60}
end
end
end
end
end
end
end
return module
Now i need if the player Luck value are higher/bigger he will easily get a rarest/harder items.
The Data is a Instance i mean is a Player Data Instance so all datas is on inside
Its a ModuleScript btw
Thanks…