I’m trying to make something that gets random hats from the marketplace. Is there a way I can do this? Is there a range of IDs to get accessories?
Thanks!
I’m trying to make something that gets random hats from the marketplace. Is there a way I can do this? Is there a range of IDs to get accessories?
Thanks!
You could use math.random to pick a random item id and then plug it in to the id
It wouldn’t really work. Try going in the catalog and opening a random hat, then adding +1 to the Id. You might just get a game, an asset or anything.
Hey, Chez_Guy! I believe the function I’ve made below is what you’re looking for. Although, I haven’t done much testing with it though, so if it errors please let me know!
I did experience one error where deleted assets can be retrieved and will not be inserted (obviously) so depending on your use for this, I’d advise you to fix this; I would have but I did not have enough time to spare in order to fix it.
I used the following resource to make this script: External Catalog Queries | Documentation - Roblox Creator Hub
local httpService = game:GetService("HttpService")
local function getRandomAssetIDFromCatalog()
local catalogURL = "https://catalog.roproxy.com/v1/search/items/details?Category=11&SortType=0&Limit=30"
local decodedData = httpService:JSONDecode(httpService:GetAsync(catalogURL))
local getPage = math.random(1, 17) -- IIRC the limit is 17 pages
local assetReceivedIndex = math.random(1, 30)
if getPage ~= 1 and decodedData.nextPageCursor ~= nil then
for index = 1, getPage do
catalogURL = "https://catalog.roproxy.com/v1/search/items/details?Category=11&SortType=0&Limit=30&Cursor="..decodedData.nextPageCursor
decodedData = httpService:JSONDecode(httpService:GetAsync(catalogURL))
end
end
return decodedData.data[assetReceivedIndex].id
end
print(getRandomAssetIDFromCatalog())
If this fits what you needed, I’d appreciate it being marked as a solution!
thank you so much for the code sample! isn’t roproxy against TOS? it seems useful but I don’t want to risk it and get banned
You’re welcome! And nope, RoProxy isn’t against the TOS, or at least it isn’t to my knowledge. I went through the TOS and saw nothing relating to it and also found nothing on the devforum about it.
ayyyyy, just tried it, it works! thanks so much!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.