How can I loop through all of the user’s T-Shirts that they have put up for sale?
I want to achieve something like the ‘Donate Pls’ game. As you can see, they were able to get the player’s owned tshirts and put them all on the gui.
I have no idea how to do this and any other posts relating to this don’t work for me.
I have no idea where to start. I found this from another post:
local InventoryUrl = "https://robloxdevforumproxy.glitch.me/users/inventory/list-json?assetTypeId=11&cursor=&itemsPerPage=100&pageNumber=%x&sortOrder=Desc&userId=%i"
-- In an event
local Inventory = HttpService:JSONDecode(HttpService:GetAsync(string.format(InventoryUrl, 1, plr.UserId))) -- function
for i, v in pairs(Inventory.Data.Items) do
print(v.Creator.Name)
end
local http = game:GetService("HttpService")
local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"
local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
tshirts = tshirts or {}
cursor = cursor or ""
local requestUrl = baseUrl:format(username, cursor)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 then
if result2 then
for _, tshirt in ipairs(result2.data) do
table.insert(tshirts, tshirt.id)
end
cursor = result2.nextPageCursor
if cursor then
return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
else
return tshirts
end
end
else
warn(result)
end
end
else
warn(result)
end
end
local username = "Roblox"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " ")) --1031862 1036727 1031864
When testing the same script with a user that has uploaded more than 30 t-shirts (maximum page-size per request) these were the results.
local username = "robosapien626"
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --323
print(table.concat(userTShirts, " ")) --323 shirt IDs.
That usually means you either have HTTP requests disabled in the game’s settings or your own internet connection dropped while making the request.
Your ISP may have also blocked the particular proxy being used roproxy. If this is the case then consider hosting your own proxy, there are tutorials out there for this.
For some reason I keep getting “HTTP 400 (Bad Request).” When it does http:GetAsync(requestUrl), the pcall is making it go to the warn message. How do I fix this?
what if i wanted to get the updated value for the t shirt? or do you know of a way to prevent players from buying a t shirt in game and manipulating the price of that t shirt?
for gamepasses you just get the updated value and check. but for t shirts that value does not hold true.