How would I access a players assets (t-shirt, shirt, gamepasses etc) that they have onsale and display them on a screen gui? I’d really appreciate any help as i’m quite new to coding.
You can definitely display items in peoples inventory however, there is no way to directly sell these items through your game, only display them.
Thanks, surely there is a way as games like pls donate exist?
You’d just need to get the user’s on-sale assets via an API (you’ll need to use a proxy API if you’re querying Roblox, as they don’t allow API requests within Roblox itself, I recommend creating one yourself) look at this post for more info on it, create GUI’s for each item a player owns (limiting it to top 4 maybe by cost?) then use PromptPurchase to prompt the user who clicks on the GUI button with a purchase to buy the asset.
NOTE: The items are limited to t-shirts, I can see if there’s a solution for other assets.
Thanks it makes a lot more sense now, the only thing I don’t understand is how I would put a each separate item on a button? Would I do something like get the number of assets it returns and clone a button that many times?
Exactly that, once you get back that list of assets/shirts (as shown in that first post I sent), you’d iterate/loop through each one per player, create/clone the GUI and bind the functionality to the button (MouseButton1Click) that calls a PromptPurchase with that AssetId (which hopefully you’d be able to access when you loop through each one).
So in short, yes you have the right idea.
Amazing thanks for your help
jgkolfdgdf
Sorry just a quick question, I’m new to scripting so not sure if the script from the link you sent should be in a server script or a local script? As I added it into my server one and got an error message
I’d do the asset getting on a server script (don’t think you have a choice on this as HttpService only works on the server side). It’s your choice whether to create the GUI’s on the server or client. I’d do it on the client by calling a remote event to all clients with :FireAllClients(assetData) (assetData would be what the API call retrieves), but any would work fine. What error is it like?
Use this way of getting the assets instead, it’s a much better answer.
So I used the script above and the only thing I changed was where it said username = “Roblox”.
Errors:
’ HTTP 400 (Bad Request) - Server - Arena1Script:197
19:33:00.163 ServerScriptService.Arena1Script:203: attempt to get length of a nil value’
The part of the script:
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 = winner.Name
local userTShirts = getUserGeneratedTShirtsRecursive(username)
print(#userTShirts) --3
print(table.concat(userTShirts, " ")) --1031862 1036727 1031864
Thanks
Does Roblox have T-Shirts that they created? It’s the only thing I can think of, it’s what ‘ServerScriptService.Arena1Script:203: attempt to get length of a nil value’’ would tell me.
I think the code may not work anymore, because I tested it in an empty server script and kept the code how it was in the beginning and still got the error
Ah, it’s the API call that’s the issue, called it myself and it’s outdated. This is the one you want now. https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=55&CreatorName=roblox&salesTypeFilter=1
All it uses is the catalog search API, so if you searched in the marketplace, just copy everything after and including the ? in the typical catalog search url and it’d work fine when you add it in place of what’s above (the ? and after it). Have an experiment with it.
Perfect, its working thank you so much for your help
Actually I thought it was working, but the buttons appearing are the same everytime, despite the player changing. Its always these two buttons that appear, I’d really appreciate any help, i’ve been trying to figure it out for a couple days.
Apologies for the late response! What’s the code you have in place that creates these GUI buttons?
Thanks for your response, but I’ve sorted it all out now, its all working great, thanks for your help from before
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.