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
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?
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