avatarEditorService:SearchCatalog() returns instance instead of a table

hello ive been trying to make a avatar editor, i did a test script to familirise myself whit avatarEditorService and catalogsearchparms but one weird thing stood out

image

ive tried searching on the doccumentation and so far i dint find anything about it
current script:

local avatarEditorService = game:GetService("AvatarEditorService")

local params = CatalogSearchParams.new()
params.SearchKeyword = "Test"
params.MinPrice = 0
params.MaxPrice = 10000
params.AssetTypes = {Enum.AvatarAssetType.Hat}
params.IncludeOffSale = true
params.Limit = 120
local searchedstuff = avatarEditorService:SearchCatalog(params)

print(searchedstuff)
1 Like

Hi there, maybe you could try this script, it works fine for me…

local avatarEditorService = game:GetService("AvatarEditorService")

local params = CatalogSearchParams.new()
params.SearchKeyword = "[V1] Black Pierced Wide Brim Hat"
params.AssetTypes = {Enum.AvatarAssetType.Hat}
params.IncludeOffSale = true
params.Limit = 10

local success, searchedstuff = pcall(function()
	return avatarEditorService:SearchCatalog(params)
end)

if success and searchedstuff then
	local firstPage = searchedstuff:GetCurrentPage() 

	if firstPage then
		for _, item in pairs(firstPage) do
			print(item.Name, item.Id)
		end
	else
		warn("Nothing found :/")
	end
else
	warn("Search failed")
end

Edit: Please don’t make the limit higher because the search will fail because its too much

This is intended to be this way (for some reason). It returns an object or instance called CatalogPages that has a few methods.

Please check out the docs for SearchCatalog() here:

I think in your code, you could do the following to print every item in the current page of the catalog search results:

if searchedstuff then
   local currentPage = searchedstuff:GetCurrentPage() 
   for i,v in currentPage do
      print(`Result {i}: {v.Name}, {v.Id}`)
   end
end

Like the others said, this is expected behaviour. Pages objects are Roblox’s way of doing paginated data - it avoids creating one absolutely massive table with loads of entries in it. And, well, since the AvatarEditorService can’t consistently predict how many returns it will get (cause issues between returning tables and pages), it just returns a pages object no matter what. The same goes for things like DataStore:ListKeysAsync().

You can iterate over all assets like so:

while (not searchedstuff.IsFinished) do
    local page = searchedstuff:GetCurrentPage()

    for k, v in next, page, nil do
        --etc.
    end

    searchedstuff:AdvanceToNextPageAsync()
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.