Hello, i’m creating a “pls donate” game, and i need to load the assets of the player.
The pants, shirts, t-shirts, gamepasses.
I’ve achieved this by using this function here:
local http = game:GetService("HttpService")
local assetid = {
["TShirt"] = 2,
["Shirt"] = 11,
["Pant"] = 12,
["GamePass"] = 34
}
local function GetContent(username,userid)
local Contents = {}
for iid,v in pairs(assetid) do
local linkforplayer = "https://search.roproxy.com/users/inventory/list-json?assetTypeId="..v.."&cursor=&itemsPerPage=100&pageNumber=%25x&sortOrder=Desc&userId="..userid
local datafromlink = http:GetAsync(linkforplayer,true)
local readabledata = http:JSONDecode(datafromlink)
local suc, er = pcall(function()
for i,v in pairs(readabledata["Data"]["Items"]) do
if v["Creator"]["Id"] == userid then
if iid == "GamePass" then
local Asset = MS:GetProductInfo(v["Item"]["AssetId"],Enum.InfoType.GamePass)["PriceInRobux"]
if Asset ~= nil then
Contents[iid.." "..i] = v["Item"]["AssetId"]
end
else
local Asset = MS:GetProductInfo(v["Item"]["AssetId"])["PriceInRobux"]
if Asset ~= nil then
Contents[iid.." "..i] = v["Item"]["AssetId"]
end
end
end
end
end)
if not suc then
warn(er)
end
end
return Contents
end
But sadly, it’s incredibly slow. I’m wondering if there’s any way i can make it more secure, and faster.
Easy, make your own private roblox proxy thats very fast and can handle high traffic.
Eitherway i couldn’t find any built-in api that can do this while making a ‘pls donate’ game, so you either have to stick to that script,use my solution or make the user put an asset id. Good luck on your game though! I’d be very jealous if its successful lol
fair enough, if i do the asset id thing litteraly like 99% of the players who play these stupid games won’t understand it.
I also keep having HTTP errors, although i can retry, and retry untill it suceeds, that wouldn’t work that well.
btw, it takes like 15-20 seconds to load all the data.
Maybe i should save it to a datastore the first time you join or something.
I ended up putting it in a task.spawn() and just letting each HTTP happen at the same time, it makes it a bit faster atleast
Edit: I also put nocache to false, so now it’s only like 2 seconds. Nice.
local http = game:GetService("HttpService")
local assetid = {
["TShirt"] = 2,
["Shirt"] = 11,
["Pant"] = 12,
["GamePass"] = 34
}
local function GetContent(username,userid)
local Contents = {}
local Count = 0
local DidError = false
local success, Error = pcall(function()
for iid,v in pairs(assetid) do
task.spawn(function()
local linkforplayer = "https://www.roproxy.com/users/inventory/list-json?assetTypeId="..v.."&cursor=&itemsPerPage=50&pageNumber=%25x&sortOrder=Desc&userId="..userid
local datafromlink = http:GetAsync(linkforplayer,false)
local readabledata = http:JSONDecode(datafromlink)["Data"]["Items"]
for i,v in pairs(readabledata) do
if v["Creator"]["Id"] == userid then
if iid == "GamePass" then
local Asset = MS:GetProductInfo(v["Item"]["AssetId"],Enum.InfoType.GamePass)["PriceInRobux"]
if Asset ~= nil then
Contents[iid.." "..i] = v["Item"]["AssetId"]
end
else
local Asset = MS:GetProductInfo(v["Item"]["AssetId"])["PriceInRobux"]
if Asset ~= nil then
Contents[iid.." "..i] = v["Item"]["AssetId"]
end
end
end
end
Count += 1
end)
end
end)
if not success then
print(Error)
Contents = {}
return GetContent(username,userid)
end
repeat task.wait() until Count == 4 or not success
if success then
return Contents
end
end
If you want to evaluate it, here you go.
Also, this may definetely be less optimized than the other one, but it’s way faster.