Help With Tables and Looping

I am trying to loop through items, but in items there are 2 dictionarys , which in one of them are 3 tables, I wanna get the Weapons dict, but also the other one “Armor” that has 3 tables, but I want the contents of those 3 tables aswell as the weapons contents , but only contents of those 3 tables not the tables, If anyone has idea on how to do so Please Answer the thread, Please read this description for good understanding.

local Datastore =require(game.ServerScriptService["Data / Important"].Datastore) 

local function setup(Player)
	local Profile = Datastore[Player]
	local Inventory = Profile.Data.Items
	local PlrGui = Player:WaitForChild("PlayerGui")
	local InventoryMainGui = PlrGui:WaitForChild("Inventory")
	local InventoryGui = InventoryMainGui:WaitForChild("MainFrame"):WaitForChild("Inventory")
	
	


	for _, inv in pairs(Inventory) do
	
		
			
		
		
		
	end
	
	
end


Make a recursive table search function, in this function you will pass 2 arguments, the current level and level you are searching, this function will be nested in you thing.

local Datastore =require(game.ServerScriptService["Data / Important"].Datastore) 

local function setup(Player)
local Items = {}
local Profile = Datastore[Player]
local Inventory = Profile.Data.Items
local PlrGui = Player:WaitForChild("PlayerGui")
local InventoryMainGui = PlrGui:WaitForChild("Inventory")
local InventoryGui = InventoryMainGui:WaitForChild("MainFrame"):WaitForChild("Inventory")

local function SearchItems(SearchItem,CurrentLevel,DesiredLevel) do
     if CurrentLevel ~= DesiredLevel then
          for _,Object in ipairs(SearchItem:GetChildren()) do
              SearchItems(Object,CurrentLevel-1,DesiredLevel)
          end
          return nil
     end
     for _,Object in ipairs(SearchItem:GetChildren()) do
         table.insert(Items,Object)
     end
end
    SearchItems(Inventory,3,1)
    print(Items)
end

What are these

I don’t understand this when I quickly read it

Did you mean get all the contents from 3 tables from those Weapon and Armor Dictionarys?

There are 3 tables in armor, none in Weapon,(I need the tables contents from the armor) ,but I also need the contents of the weapon dictionary

Do this

function search(mainTable)
    if type(mainTable) == "Table" then
        for _ , v in pairs(mainTable) do
            print(v)
            search(v)
        end
    end
end

This will print all the values inside the table that you give whether its inside another table or not

If you want to loop but with an instance just do

Instance:GetDescendants() --in a for loop

How can this help with my issue?

It will print all the items you can replace the print with what you want to do with them…

Yeah, but that does them all, I was wondering can I at once somehow get the ‘Weapons’ dict aswell as the contents of 3 tables inside ‘Armor’ dict

Show me the module containing them, i’all help you

Näyttökuva 2022-07-31 221017

I mean thats all there is to know about them, I need to get all of those 3 tables contents aswell as the contents of ‘Weapons’ , is there a way to get them all at once?

I guess “items” is the module

Use the function i gave you with armor, other than printing add them to another table in that script called armors, and same with weapons, you will have all of each type in the correct table