Hi i want to make a system where you can view the bestselling gamepass in the game but i cant get it to work here is the script btw
local mps = game:GetService("MarketplaceService")
local iD = 51963507
local info = mps:GetProductInfo(iD)
print(info.PriceInRobux)
print(info.Sales)
print(info.IconImageAssetId)
for now it only prints
Just put the ids of all the gamepasses in table and another table for the sales then do table sort for the sales and get the table[1]
Try this
local mps = game:GetService("MarketplaceService")
local iD = {51963507,51963507,51963507}
local bestselling,id
local info = mps:GetProductInfo(iD)
for i,v in pairs(ID) do
if i = 1 then bestselling = v,id = mps:GetProductInfo(v) return end
if ID:GetProductInfo(v) > id then bestselling = v , id = ID:GetProductInfo(v) return end
end
There might be typos tho
1 Like
Okay I’ll try that btw the price is nil and the iconImageAssetId and sales are 0 while it does have a image and i bought it do you know how?
API might have failed to return the result try using pcall function and see if there success then run your code
IF YOU DID EVERYTHING RIGHT
Could be that you’re not specifying the asset type
Try specifying as well
GetProductInfo(ID, Enum.InfoType.GamePass)
Also @hakobmher You gave a good example, but it’s a bit hard for people to properly read it, I recommend writing your code in a text editor like Notepad/Notepad++ and then copying and pasting it here rather than working directly from here
local ids = [15346, 636347]
local currentBest
for _, id in ipairs(ids) do
local info = GetProductInfo(id, Enum.InfoType.GamePass)
if not currentBest then
currentBest = info
continue
end
if currentBest.Sales >= info.Sales then
continue
end
currentBest = info
end
2 Likes
this could work perfect, thank you very much