I’ve been playing a little with AvatarEditorService. I have a doubt. When using GetInventory() even when adding all possible params I’m not getting the entire inventory of the player, seems that it has a limit of items it can obtain (which I can’t find in the documentation). Same when using SearchCatalog() and similar.
Is there a way to perform a loop to get the entire inventory/assets of a player?
If its not, is AES really reliable?
For tasks like this where its needed to read all the items a player owns what would be the best approach you could suggest?
Hey there! AvatarEditorService’s GetInventory() method has a return type of InventoryPages (Documentation), which similarly to other Pages types, only allows you to view a certain amount of items at a time.
All pages work this way, however this doesn’t mean you cannot access the remaining items, you simply need to use the InventoryPages’s AdvanceToNextPageAsync() method.
Calling this method will “turn” to the next page, which will allow you to view the next page of items.
To fetch all items in an Inventory, you would need to loop over each page and store the values.
This could be achieved like this:
local AvatarEditorService = game:GetService("AvatarEditorService")
AvatarEditorService:PromptAllowInventoryReadAccess()
AvatarEditorService.PromptAllowInventoryReadAccessCompleted:Wait()
local AssetTypes = {Enum.AvatarAssetType.Hat}
local InventoryPages = AvatarEditorService:GetInventory(AssetTypes)
local Inventory = {}
while true do
CurrentPage = InventoryPages:GetCurrentPage()
for _,Item in CurrentPage do
table.insert(Inventory,Item)
end
local Success,_ = pcall(InventoryPages.AdvanceToNextPageAsync,InventoryPages)
if not Success then break end
end
print(Inventory)
You are totally right, thank you so much. Actually I did try to getNextPage of the Instance got… somehow I made a mess and I was unable to get any result from that, I was thinking that the pages got from the method was not having actual pages… lol my mistake…
Your first script fixed my issue totally, obviously I had to add the error handling for next page with a pcall. But, it works perfect.
After you edited your reply with that code which actually doesn’t work (as plug&play), check it. Nevertheless your previous code was the solution for me after some tweaking, thank you!