Making an script which gonna give some item with chance(50 items)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    So basically topic is a big complicated, i’m working on game inspired by luck simulator better(if you know it),here is screenshot:
    image
    Alright so i’m currently working on smth like that, you can see my code below
    Also here is text explain of this
    Player have an GUI:
    image
    Each of these Generator have own chance, own production and own amount,
    I currently adding an array in table for Production
    So each 2 seconds every generator depends on it amount gives power(or money if this is easier to understand)
    Amount | GenNumber | Production | Exact Production
    1 | 1 | 1 | Amount Production(1 1 = 1)
    5 | 2 | 25 | Amount Production(5 25 = 125)
    And etc
    And each 2 seconds there an chance what you get new generator like
    Chance | GenTier | Amount
    50 | 1 | 1 or 0
    100 | 1 | 1

And also if chance is already 100 you just get more luck like:
First upgrade after chance 100 gives 1 gen
Second upgrade after chance 100 gives 2gen
and etc.
2. What is the issue? Include screenshots / videos if possible!
Idk how to do that
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tryed to use for loops, but they don’t seems to work

Here is my code:

local SSS = game:GetService("ServerScriptService")
local GameInstancesModule = require(SSS.GameInstancesModule)
local Players = game.Players
Players.PlayerAdded:Connect(function(plr)
	print("PlayerAdded")
	local PlrGUI = plr.PlayerGui
	local PowerVal = plr:WaitForChild("leaderstats").Power
	local PlayerLuck = plr.Stats.PlrLuck
		for i,v in ipairs(GameInstancesModule.Chances) do
		local TrueChance = v/PlayerLuck
		print(TrueChance)
		local randomNumber = math.random(1,v)
		print(randomNumber)
				if randomNumber == 1 then
				for i,k in ipairs(GameInstancesModule.Amount) do
					k += 1
					print(k)
				end
				end
				wait(0.01)
	end
end)

Also here is table of Chances and Production

local ChancesTable = {
	["Chances"] = {
	Gen1 = 1,
	Gen2 = 125,
	Gen3 = 1250,
	Gen4 = 12500,
	Gen5 = 125000,
	Gen6 = 1250000,
	Gen7 = 12500000,
	Gen8 = 125000000,
	Gen9 = 1250000000,
	Gen10 = 12500000000,
	Gen11 = 250000000000,
	Gen12 = 5000000000000,
	Gen13 = 100000000000000,
	Gen14 = 2000000000000000,
	Gen15 = 40000000000000000,
	Gen16 = 800000000000000000,
	Gen17 = 16000000000000000000,
	Gen18 = 320000000000000000000,
	Gen19 = 6400000000000000000000,
	Gen20 = 128000000000000000000000,
	Gen21 = 12800000000000000000000000,
	Gen22 = 1280000000000000000000000000,
	Gen23 = 128000000000000000000000000000,
	Gen24 = 1280000000000000000000000000000,
	Gen25 = 128000000000000000000000000000000,
	Gen26 = 12800000000000000000000000000000000,
	Gen27 = 1280000000000000000000000000000000000,
	Gen28 = 128000000000000000000000000000000000000,
	Gen29 = 12800000000000000000000000000000000000000,
	Gen30 = 1280000000000000000000000000000000000000000,
	Gen31 = 128000000000000000000000000000000000000000000,
	Gen32 = 12800000000000000000000000000000000000000000000,
	Gen33 = 1280000000000000000000000000000000000000000000000,
	Gen34 = 128000000000000000000000000000000000000000000000000,
	Gen35 = 12800000000000000000000000000000000000000000000000000,
	Gen36 = 1280000000000000000000000000000000000000000000000000000,
	Gen37 = 128000000000000000000000000000000000000000000000000000000,
	Gen38 = 12800000000000000000000000000000000000000000000000000000000,
	Gen39 = 1280000000000000000000000000000000000000000000000000000000000,
	Gen40 = 128000000000000000000000000000000000000000000000000000000000000,
	Gen41 = 256000000000000000000000000000000000000000000000000000000000000000,
	Gen42 = 512000000000000000000000000000000000000000000000000000000000000000000,
	Gen43 = 1024000000000000000000000000000000000000000000000000000000000000000000000,
	Gen44 = 2048000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen45 = 4096000000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen46 = 8192000000000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen47 = 16384000000000000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen48 = 32768000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen49 = 65536000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
	Gen50 = 131072000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
	},

	["Production"] = {
		Gen1 = 1,
		Gen2 = 25,
		Gen3 = 250,
		Gen4 = 1250,
		Gen5 = 6250,
		Gen6 = 31250,
		Gen7 = 156250,
		Gen8 = 781250,
		Gen9 = 3906250,
		Gen10 = 19531250,
		Gen11 = 100000000,
		Gen12 = 1000000000,
		Gen13 = 10000000000,
		Gen14 = 100000000000,
		Gen15 = 1000000000000,
		Gen16 = 10000000000000,
		Gen17 = 100000000000000,
		Gen18 = 1000000000000000,
		Gen19 = 10000000000000000,
		Gen20 = 100000000000000000,
		Gen21 = 2000000000000000000,
		Gen22 = 40000000000000000000,
		Gen23 = 800000000000000000000,
		Gen24 = 16000000000000000000000,
		Gen25 = 320000000000000000000000,
		Gen26 = 6400000000000000000000000,
		Gen27 = 128000000000000000000000000,
		Gen28 = 2560000000000000000000000000,
		Gen29 = 51200000000000000000000000000,
		Gen30 = 1024000000000000000000000000000,
		Gen31 = 20000000000000000000000000000000,
		Gen32 = 800000000000000000000000000000000,
		Gen33 = 32000000000000000000000000000000000,
		Gen34 = 1280000000000000000000000000000000000,
		Gen35 = 51200000000000000000000000000000000000,
		Gen36 = 2048000000000000000000000000000000000000,
		Gen37 = 81920000000000000000000000000000000000000,
		Gen38 = 3276800000000000000000000000000000000000000,
		Gen39 = 131072000000000000000000000000000000000000000,
		Gen40 = 5242880000000000000000000000000000000000000000,
		Gen41 = 100000000000000000000000000000000000000000000000,
		Gen42 = 10000000000000000000000000000000000000000000000000,
		Gen43 = 1000000000000000000000000000000000000000000000000000,
		Gen44 = 100000000000000000000000000000000000000000000000000000,
		Gen45 = 10000000000000000000000000000000000000000000000000000000,
		Gen46 = 1000000000000000000000000000000000000000000000000000000000,
		Gen47 = 100000000000000000000000000000000000000000000000000000000000,
		Gen48 = 10000000000000000000000000000000000000000000000000000000000000,
		Gen49 = 1000000000000000000000000000000000000000000000000000000000000000,
		Gen50 = 10000000000000000000000000000000000000000000000000000000000000000000
	}
	}
return ChancesTable

Also i need an rework, i need amount in player, is there an client table or smth like that to save player gen amount easier

Here is new script:

local SSS = game:GetService("ServerScriptService")
local GameInstancesModule = require(SSS.GameInstancesModule)
local Players = game.Players
Players.PlayerAdded:Connect(function(plr)
	wait(3)
	print("PlayerAdded")
	local PlrGUI = plr.PlayerGui
	local PowerVal = plr:WaitForChild("leaderstats").Power
	local PlayerLuck = plr.Stats.PlrLuck
	local pName = plr.Name
	local pCharacter = workspace:FindFirstChild(pName)
	local pHead = pCharacter:WaitForChild("Head")
	local AGGUI = pHead:FindFirstChild("AdvancedGameGUI")
	local Frame = AGGUI:WaitForChild("Frame")
	for i,v in ipairs(GameInstancesModule.Chances) do
		print(i,v)
		local TrueChance = v/PlayerLuck
		print(TrueChance)
		local randomNumber = math.random(1,v)
		print(randomNumber)
				if randomNumber == 1 then
			for i,lines in ipairs(Frame:GetChildren()) do
				for i, values in ipairs(lines:GetDescendants()) do
					if values.Name == "Amount" then
						values.Value += 1
					end
				end
			end
				end
				wait(0.01)
	end
end)

Edit: Also after this line

for i,v in ipairs(GameInstancesModule.Chances) do

nothing works, even print(i,v)