Percentages in a Table?

I’m making a crate opening system and I was wondering, how would I apply percentages through a table? I’ve looked at a decent amount of tutorials on this but they all have the same method, writing the Percentages and the items beforehand


local Items = {
      Sword = 25,
      Sword2 = 75,

However, with my script, how would I use the for I, x in pairs method to add the items and attach a percentage value on them if I already have a given “Folder” of all the items

My code:

local function NormalDryer(player)
	local Assets = game.ServerStorage.Assets
	local ItemList = {}
	for i, x in pairs(Assets:GetChildren()) do
		if x.Rarity.Value == 'Common' then
			table.insert(ItemList, x.Name) -- I want like,  (ItemList, x.Name, 25)    (25 being percentage)
	local function getTotalPercentage(table)
		local total = 0
		for _, v in ipairs(table) do
			total += v
		return total

	local function getRandom(table)
		local random = math.random(1, getTotalPercentage(table))
		local total = 0
		for _, v in ipairs(table) do
			total += v.Rarity
			if random <= total then
				return v.Ability
		return nil

I want it so I can loop to an existing Folder, insert each children into a table but with an attached percentage. Basically, doing the first method but instead of writing each item one by one, it’ll do it automatically

Please search before making a topic.

P.S I can confirm this works, I have used it many times for games and YouTube tutorials. The answer is the guy with 15 likes, that explained the script