I need help with my luck in this rarity system

I made this rarity system and i have the function where it control everything but there something wrong

I was adding a luck thing in my script but whenever I try to customize it, it wont work.

I try using AI to fix the problem but it didn’t help.

This is the script

local chance = 1

game:GetService("ReplicatedStorage").Remotes.UpdateLuck.OnServerEvent:Connect(function(player)
	print(player)
	chance = player.Luck.Value
end)

return {
	getRandomIndex = function(chances)
		for i, v in ipairs(chances) do
			local RandNum = math.random(1, v[2])
			if RandNum / chance then
				RandNum = RandNum / chance

				if RandNum == 1 and v[2] > chances[1][2] then
					print(RandNum)
					return {
						v[1];
						v[2];
						v[3];
						v[4];
					}
				end
			else
				RandNum = 3
				print(RandNum)
			end
		end

		return chances[1]
	end,
}

What does the chances table look like?

Also, when you say it won’t work, could you describe what it’s doing?

so whenever I change the luck value to whatever number i pick it doesnt work and then the RandNum variable stay as 3 and when i try again it still wont work

and this is what the chance table look like

return {
	{"Linked Sword", 3, Color3.fromRGB(143, 143, 143), Font.fromEnum(Enum.Font.BuilderSansMedium) },
	{"Claymore", 5, Color3.fromRGB(255, 255, 255), Font.fromEnum(Enum.Font.Fantasy) },
	{"Bombo's Knife", 10, Color3.fromRGB(74, 74, 74), Font.fromEnum(Enum.Font.Highway) },
	{"Farmer's Revenge", 20, Color3.fromRGB(136, 93, 50), Font.fromEnum(Enum.Font.Creepster) },
	{"Ice Cream", 100, Color3.fromRGB(248, 151, 255), Font.fromEnum(Enum.Font.Arcade) },
	{"Turkey Leg", 333, Color3.fromRGB(84, 67, 43), Font.fromEnum(Enum.Font.Arimo) },
	{"Firebrand", 666, Color3.fromRGB(149, 9, 9), Font.fromEnum(Enum.Font.Bodoni) },
	{"Sledge Hammer", 1500, Color3.fromRGB(129, 122, 80), Font.fromEnum(Enum.Font.Antique) },
	{"Cheezburger", 2000, Color3.fromRGB(245, 177, 18), Font.fromEnum(Enum.Font.Fondamento) },
	{"Windforce", 11100, Color3.fromRGB(192, 255, 255), Font.fromEnum(Enum.Font.IndieFlower) },
	{"Illumina", 2200000, Color3.fromRGB(235, 195, 231), Font.fromEnum(Enum.Font.PermanentMarker) },
	{"Darkheart", 50000000, Color3.fromRGB(0, 0, 0), Font.fromEnum(Enum.Font.PatrickHand) },
	{"Ban Hammer", 1000000.0000001, Color3.fromRGB(137, 153, 255), Font.fromEnum(Enum.Font.LuckiestGuy) },
}