Feedback on a rarity system

I know, I know. Weight system exists. I just made this for fun.

Code :

``local Items = {
{“Emerald”, 0.1},
{“Diamond”, 1},
{“Gold”, 5},
{“Iron”, 25},
{“Copper”, 50},
{“Stone”, 75},
{“Wood”, 90}
}

local MaxItem = {
Name = “”,
Percent = 0
}

local RangeTable = {}
local LastRange = 0
local CanResultNothing = true

local function sorter(t1, t2)
return t1[2] < t2[2]
end
table.sort(Items, sorter)

for i, v in pairs(Items) do
local Num = v[2]
local ItemName = v[1]
table.insert(RangeTable, {ItemName, LastRange, Num})
LastRange = Num

if Num >= MaxItem.Percent then
MaxItem.Percent = Num
MaxItem.Name = ItemName
end
end

local RNG = math.random(1, 1000)/10

for i, v in pairs(RangeTable) do
local From = 0
local Till = v[3]
if RNG > From and RNG <= Till and RNG <= MaxItem.Percent then
print(v[1])
break
elseif RNG >= From and RNG >= MaxItem.Percent then
if CanResultNothing == false then
print(MaxItem.Name)
elseif CanResultNothing == true then
print(“Nothing! Better luck next time.”)
end
break
end
end

print(RNG)``