How do I make this getting asset sales code faster?

      local MarketplaceService = game:GetService("MarketplaceService")
      local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
      local TotalSales = 0
      for i = 1,#IDS do
			local Asset = game:GetService("MarketplaceService"):GetProductInfo(IDS[i])
            TotalSales= TotalSales + Asset.Sales

The “IDS” array includes up to 1000 different asset Ids so It takes time to complete the whole process, however, is there any way to make it work faster?

Yes, by removing the wait, of course. GetProductInfo has some invisible limit last I remember though, so you’re kind of forced to have that wait or you could instead find a different way to achieve what you need, whatever that may be - up to your own web server that does this heavy lifting instead of your game code.

1 Like

Removing the wait gives the error of too many requests, so that’s why I am using it. Other than that how do I do that in my own web server, can you provide any reference that I can refer to?
I was also suggested to do this:
Filter the check by finding if the first 4 or 5 integers of that Id matches, then it would make it search faster. So, get their asset id , filter the first 3-4 numbers of their Id and then it should reduce the amount of requests.

You won’t be able to make this code go any faster necessarily then, if the wait is required. This becomes your bottleneck: needing to depend on the wait as well as any extra seconds the function waits for an open slot in the task scheduler.

In terms of doing this on your own web server, essentially what you’re doing is passing off the heavy lifting. Your game server would be querying data from your server and the server would perform the sales checks on all given items, whether the list is stored on your server or in your Roblox game (if you’re using a web server, might as well put the list there too).

I’m not too sure what that other recommendation is and I don’t want to make any assumptions about how effective that actually is (if it is at all), so I can’t offer any comment on it. Sounds unnecessarily overcomplicated, that much I can say.

1 Like

So do you mean that I should create my own web server where everything will be calculated and then send the data to my Roblox game?

yes, you can do this with things such as Noblox.js with heroku or glitch

I contacted a web developer and he told me that it would take the same amount of time so my problem will still be there :confused: