Okay, this is annoying. I do not have as many inventory items as you (You have 2780, I have 733.

Perhaps you are getting throttled by roproxy (Unlikely as their post says there is no rate limiting)? This would make sense as you would be sending 28 requests, you may also just be waiting for the pure compute time.

There might not be a super easy solution to reduce the waiting time

I’ve quickly whipped up this Python program to see how long everything takes:

timings.py

""""
A program designed to count the waiting time for roproxy.com

This program was not designed with efficiency in mind but rather replicating the MainModule used by the pls donate kit.

Get asset types: https://create.roblox.com/docs/reference/engine/enums/AssetType

"""
import time
import requests

startTime = time.time()
assetIds = [2, 11, 12, 34]
userId = 1012243713

def getItems(assetId):
    cursor = ""
    while True:
        request = requests.get(f"https://www.roproxy.com/users/inventory/list-json?assetTypeId={assetId}&cursor={cursor}&itemsPerPage=100&userId={userId}")
        requestJson = request.json()
        nextCusor = requestJson["Data"]["nextPageCursor"]
        if nextCusor == None:
            break
        else:
            cursor = nextCusor


for assetId in assetIds:
    getItems(assetId)
endTime = time.time()
finalTime = endTime - startTime
print(f"Time taken: {finalTime}")

After testing with your user ID (I think) time taken was 106 seconds, which is quite a long time to load in the assets for a single user, for me, it took 18 seconds, but of course, this is also too long.


The potential solution?

Perhaps, instead of waiting for all the data to be loaded before you add items, why not add items after each request?

Unfortunately due to the way that the main module is structured, this may quite a lot of code to be re-written.

I’ve attempted to re-write the module for you and it should work, heck, it’s not the best code for sure, but it should work. The data will add not sorted, but once all items are loaded, the items will be sorted but at least your stand has items.

MainModule.lua (Modified):

local module = {}
local dss = game:GetService("DataStoreService")
local http = game:GetService("HttpService")
local mps = game:GetService("MarketplaceService")
local mainStore = dss:GetDataStore("MainDataStore")

module.assetTypeIds = {
	["T-Shirt"]=2,
	["Shirt"]=11,
	["Pants"]=12,
	["Pass"]=34,
}

 module.getItems = function(assetId,plrId, stand, plr)
	local allItems = {}
	local createdByUser = {}
	local success, errormsg = pcall(function()
		local done = false
		local nextPageCursor
		while done == false do
			local data
			if nextPageCursor then
				data = http:GetAsync("https://www.roproxy.com/users/inventory/list-json?assetTypeId="..tostring(assetId).."&cursor="..nextPageCursor.."&itemsPerPage=100&userId="..tostring(plrId))
			else
				data = http:GetAsync("https://www.roproxy.com/users/inventory/list-json?assetTypeId="..tostring(assetId).."&cursor=&itemsPerPage=100&userId="..tostring(plrId))
			end
			if data then
				data = http:JSONDecode(data)
				local items = data["Data"]["Items"]
				for _, item in pairs(items) do
					table.insert(allItems, item)
					print(item["Item"]["Name"])
				end
				if data["Data"]["nextPageCursor"] then
					nextPageCursor = data["Data"]["nextPageCursor"]
					print(nextPageCursor)
				else
					done = true
				end
			else
				warn("No data.")
			end
			tempItems = {}
			for i, item in pairs(allItems) do
				pcall(function()
					if (item["Creator"]["Id"] == plrId) and (item["Product"]["IsForSale"] == true) then
						print("added item")
						table.insert(createdByUser,item)
						table.insert(tempItems, item)
					end
				end)
			end
			table.sort(tempItems, function(a, b)
				return a["Product"]["PriceInRobux"] < b["Product"]["PriceInRobux"]
			end)
			for _, item in pairs(tempItems) do
				if stand.ClaimedUserName.Value == plr.Name then
					local frame = script.Template:Clone()
					frame.ItemID.Value = item["Item"]["AssetId"]
					frame.Cost.Value = item["Product"]["PriceInRobux"]
					frame.ItemTypeId.Value = item["Item"]["AssetType"]
					frame.RobuxCost.Text = "$"..tostring(item["Product"]["PriceInRobux"])
					frame.Parent = stand.ItemsPart.Items.ScrollingFrame
				end
			end
		end
	end)
	return createdByUser
end

module.loadItems = function(stand, plr)
	for _, frame in pairs(stand.ItemsPart.Items.ScrollingFrame:GetChildren()) do
		if frame:IsA("Frame") then
			frame:Destroy()
		end
	end
	local tshirts = module.getItems(module.assetTypeIds["T-Shirt"],plr.UserId, stand, plr)
	local passes = module.getItems(module.assetTypeIds["Pass"],plr.UserId,stand, plr)
	local shirts = module.getItems(module.assetTypeIds["Shirt"],plr.UserId, stand, plr)
	local pants = module.getItems(module.assetTypeIds["Pants"],plr.UserId, stand, plr)
	print(#tshirts,"T-Shirts found.")
	print(#shirts,"Shirts found.")
	print(#pants,"Pants found.")
	print(#passes,"Passes found.")
	local allItems = {}
	local tble = {tshirts,passes,shirts,pants}
	for _, itemType in pairs(tble) do
		for _, item in pairs(itemType) do
			table.insert(allItems,item)
		end
	end
	--print("Total items found:",#allItems)
	table.sort(allItems, function(a, b)
		return a["Product"]["PriceInRobux"] < b["Product"]["PriceInRobux"]
	end)
	for _, frame in pairs(stand.ItemsPart.Items.ScrollingFrame:GetChildren()) do
		if frame:IsA("Frame") then
			frame:Destroy()
		end
	end
	for _, item in pairs(allItems) do
		if stand.ClaimedUserName.Value == plr.Name then
			local frame = script.Template:Clone()
			frame.ItemID.Value = item["Item"]["AssetId"]
			frame.Cost.Value = item["Product"]["PriceInRobux"]
			frame.ItemTypeId.Value = item["Item"]["AssetType"]
			frame.RobuxCost.Text = "$"..tostring(item["Product"]["PriceInRobux"])
			frame.Parent = stand.ItemsPart.Items.ScrollingFrame
		end
	end
end

module.clearStand = function(stand)
	--print("Clearing stand...")
	stand.SignPart.SurfaceGui.UserMessage.Text = "your text here"
	stand.Base.ClaimPrompt.Enabled = true
	stand.Base.ClaimedInfoDisplay.Enabled = false
	stand.Base.Unclaimed.Enabled = true
	stand.Claimed.Value = false
	stand.ClaimedUserName.Value = ""
	for _, frame in pairs(stand.ItemsPart.Items.ScrollingFrame:GetChildren()) do
		if frame:IsA("Frame") then
			frame:Destroy()
		end
	end
end

module.updateStandsEarned = function()
	for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
		if stand.Claimed.Value == true then
			local plr = game.Players:FindFirstChild(stand.ClaimedUserName.Value)
			if plr then
				stand.Base.ClaimedInfoDisplay.UserRaised.Text = "R$"..tostring(plr.leaderstats.Raised.Value).." Raised"
			else
				--print("no player but claimed")
			end
		end
	end
end

module.findItem = function(itemID)
	for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
		for _, frame in pairs(stand.ItemsPart.Items.ScrollingFrame:GetChildren()) do
			if frame:IsA("Frame") then
				if frame.ItemID.Value == itemID then
					return frame
				end
			end
		end
	end
end

return module

If this works, please mark as solution (this is deffo the longest scripting support response I’ve made ever (bleh) )

1 Like