Table turned string after playing again

So basically i made a script that saves the inventory.
It worked in studio.
Then in roblox it didn’t.
And then in Studio it didn’t too and the error says attempt to iterate over a nil value

This is the server script:

local InventoryD = DataStore:GetDataStore("Inv")
local HttpS = game:GetService("HttpService")

local DataStore = game:GetService("DataStoreService")
local Inv = DataStore:GetDataStore("InvL")


local R_INV = game.ReplicatedStorage.Inventory.Events:WaitForChild("Recieve_INV")
local Send_INV = game.ReplicatedStorage.Inventory.Events:WaitForChild("Send_INV")

local Inventory = { -- Example Player Inventory
	 	
}


game.Players.PlayerAdded:Connect(function(plr)
	local folder = Instance.new("Folder",plr)
	folder.Name = "Invent"
	

	local success,errorMessage = pcall(function()
		local data = Inv:GetAsync(plr.UserId)
		print(data)
		Invent = data
	end)
	
	if success then
		print("Data successfully loaded!")
	end
	if errorMessage then
		warn(errorMessage)
	end

	Send_INV:FireClient(plr, Invent)
	game.Players.PlayerRemoving:Connect(function(plr)
		Inv:SetAsync(plr.UserId, Inventory)
	end)

	game:BindToClose(function()
		for i,plr in pairs(game.Players:GetPlayers()) do
			Inv:SetAsync(plr.UserId, Inventory)
		end
	end)
end)


R_INV.OnServerEvent:Connect(function(plr, ID)

	local success,errorMessage = pcall(function()
		local data = Inv:GetAsync(plr.UserId)
		Invent = data
	end)
	
	table.insert(Invent, ID)
	Inv:SetAsync(plr.UserId, Inventory)

end)


Local script:

local R_INV = game.ReplicatedStorage.Inventory.Events:WaitForChild("Recieve_INV")
local InvItems = game.ReplicatedStorage.Inventory.Items
local ID = game.ReplicatedStorage.Inventory.Events:WaitForChild("ID")
local Players = game:GetService("Players")

local Weapons = script.Parent
local plr = game.Players.LocalPlayer

local PlayerInvGUI = plr.PlayerGui.Menu.Inventory.Holder.Main.Colletion.Collectionframe:WaitForChild("Weapons")

local PlayInv = {}

local DarkShotValue = 0
local AngelValue = 0

Send_INV.OnClientEvent:Connect(function(Inventory) --loads the inv to players client
	print(Inventory)
	for i,v in Inventory do -- here is the error
		print(v)
		if v == 30001 then
			
			
			for i, it in InvItems:GetChildren() do
				if it:IsA("Frame") then
					print("1")
					for i, chi in it:GetChildren() do
						if chi:IsA("IntValue") then

							if chi.Value == v then
								if table.find(PlayInv, chi.Value) then
									
									for i, G in PlayerInvGUI:GetChildren() do
										if G:IsA("Frame") then
											
											for i, E in G:GetChildren() do
												if E:IsA("IntValue") then
													
												
													if E.Value == v then
														AngelValue += 1
														G.Frame.Frame.Time.Text = AngelValue.."x"
														print(G)
														




													end
												end
											end	

										end	
									end
								else
									local Duplicate = chi.Parent:Clone()
									AngelValue += 1
									Duplicate.Parent = script.Parent
									table.insert(PlayInv, chi.Value)
									print("inserted")
								end
							
							
								

							end
						end
					end
				end
			end
		end
		if v == 10001 then
		
			for i, it in InvItems:GetChildren() do
				if it:IsA("Frame") then
					print("1")
					for i, chi in it:GetChildren() do
						if chi:IsA("IntValue") then

							if chi.Value == v then
								if table.find(PlayInv, chi.Value) then

									for i, G in PlayerInvGUI:GetChildren() do
										if G:IsA("Frame") then

											for i, E in G:GetChildren() do
												if E:IsA("IntValue") then


													if E.Value == v then
														DarkShotValue += 1
														G.Frame.Frame.Time.Text = DarkShotValue.."x"
														print(G)





													end
												end
											end	

										end	
									end
								else
									local Duplicate = chi.Parent:Clone()
									DarkShotValue += 1
									Duplicate.Parent = script.Parent
									table.insert(PlayInv, chi.Value)
									print("inserted")
								end




							end
						end
					end
				end
			end
			
		
		end
	end
	
end)

ID.Event:Connect(function(It_ID, player) --if a player bough an item
	print(It_ID)
	if It_ID == 30001 then



		for i, it in InvItems:GetChildren() do
			if it:IsA("Frame") then
				print("1")
				for i, chi in it:GetChildren() do
					if chi:IsA("IntValue") then

						if chi.Value == It_ID then
							if table.find(PlayInv, chi.Value) then

								for i, G in PlayerInvGUI:GetChildren() do
									if G:IsA("Frame") then

										for i, E in G:GetChildren() do
											if E:IsA("IntValue") then


												if E.Value == It_ID then
													AngelValue += 1
													G.Frame.Frame.Time.Text = AngelValue.."x"
													print(G)





												end
											end
										end	

									end	
								end
							else
								local Duplicate = chi.Parent:Clone()
								AngelValue += 1
								Duplicate.Parent = script.Parent
								table.insert(PlayInv, chi.Value)
								print("inserted")
							end




						end
					end
				end
			end
		end
	end 
	if It_ID == 10001 then

		for i, it in InvItems:GetChildren() do
			if it:IsA("Frame") then
				print("1")
				for i, chi in it:GetChildren() do
					if chi:IsA("IntValue") then

						if chi.Value == It_ID then
							if table.find(PlayInv, chi.Value) then

								for i, G in PlayerInvGUI:GetChildren() do
									if G:IsA("Frame") then

										for i, E in G:GetChildren() do
											if E:IsA("IntValue") then


												if E.Value == It_ID then
													DarkShotValue += 1
													G.Frame.Frame.Time.Text = DarkShotValue.."x"
													print(G)





												end
											end
										end	

									end	
								end
							else
								local Duplicate = chi.Parent:Clone()
								DarkShotValue += 1
								Duplicate.Parent = script.Parent
								table.insert(PlayInv, chi.Value)
								print("inserted")
							end




						end
					end
				end
			end
		end


	end
	print(It_ID)
	R_INV:FireServer(It_ID)
end)

What line? You have about 8 for loops in the code.

its in local script line 19 but the table is a string for some reason

Let me explain how it works, the table saves the ids of the shotguns the player should have then it should load in the inv from the local script