How would I implement a 2x Luck System with this Code?

local function SelectRarity(player)
	
	local luckboost = player.Boosts.Luck.Value
	
	local rarities = {}
	for i, v in pairs(totalStats) do
		table.insert(rarities,{v.Name,v.Value / depth})
	end
	table.sort(rarities, function(a, b)
		return a[2] < b[2]
	end)
	
	local segments = {}
	local total = 0
	
	for _, data in pairs(rarities) do 
		table.insert(segments, {total, total + data[2], data[1]})
		total = total + data[2]
	end
	
	local x = math.random(0,depth) / depth
	for _, seg in pairs(segments) do
		if seg[1] <= x and x <= seg[2] then
			print(seg[3])
			return seg[3]
		end
	end
	return "Common"
end