AssetTypeId issue

When using GetProductInfo on the roblox uploaded sword (47433), the AssetTypeId is returned as 10, which is a model. Shouldn’t it be 19, which is a gear?

I’m having trouble combining loadasset and getfreemodels to find gears made by roblox in the toolbox

local function CheckGear(assetID)
        local asset = MarketplaceService:GetProductInfo(assetID)
        print("assettypeid: ".. tostring(asset.AssetTypeId))
        print("creator id: ".. tostring(asset.Creator.CreatorTargetId))
        if asset.AssetTypeId == 19 and asset.Creator.CreatorTargetId == 1 then
            return true
        else
            return false
        end
    end
1 Like

No, the ID you provided (47433) is a model. :GetProductInfo() returns information about the given asset ID – meaning, in this case, AssetTypeId’s value would be 10. The ID for the gear is 125013769.

I think it’s worth mentioning that I’m using InsertService:GetFreeModels to search for swords. I’m trying to make it so that I can search for models, specifically gears/tools, then use LoadAsset to Load it into the game, and parent it to the player’s backpack. Sort of like Scribblenauts. That’s why I can’t really just use the raw tool’s ID.

1 Like

I think a better method would be to utilize the Marketplace API and search for gears that have the keyword "Sword" in them. Here’s a very rough example on how you could do that:

local httpservice = game:GetService("HttpService")
local url = "https://catalog.roproxy.com/v1/search/items/details?Category=11&Subcategory=5&CreatorTargetId=1&SortType=0&SortAggregation=5&Limit=30&Keyword=%s"

local function returnGearsWithKeyword(keyword, cursor, gears)
	local response = httpservice:GetAsync(string.format((cursor ~= nil and url .. "&Cursor=%s") or url , keyword, cursor))
	local data = httpservice:JSONDecode(response)
	
	local gears = gears or {}
	
	for _, entry in data.data do
		if (entry.id) then 
			table.insert(gears, entry.id)  -- Stores the asset id inside of the gears table
		end
	end
	
	if (data.nextPageCursor) then
		return returnGearsWithKeyword(keyword, data.nextPageCursor, gears)
	end
	
	return gears
end

print(returnGearsWithKeyword("Sword"))

I should note that these requests can sometimes fail, so you should wrap :GetAsync() in a pcall so you can handle the case in the event it does. Here’s the documentation page that shows you how to do that: HttpService | Documentation - Roblox Creator Hub

1 Like

That works wonderfully, I’ll alter it to fit my needs.

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