Hello fellow developers,
So i have a module script for getting all items in the players inventory for a ‘pls donate’ type game.
All items copy on the frame everything works EXCEPT the fact that when i click on the button to purchase it i get this error:
this is my module script:
local AssetManager = {}
local HttpService = game:GetService("HttpService")
local UrlA = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="
local function getUserGeneratedTShirtsRecursive(username, SignPrices, tshirts, cursor)
tshirts = tshirts or {}
local requestUrl = UrlA
local data = HttpService:JSONDecode(HttpService:GetAsync(UrlA .. username)).data
if data then
table.sort(data,
function(a,b)
return a.price < b.price
end
)
for _, item in ipairs(data) do
local e,s = pcall(function()
table.insert(tshirts, item.id)
local newBtn = script.Template:Clone()
local price = item.price
newBtn.PurchaseButton.price.Text = "$"..price
newBtn.LayoutOrder = price
newBtn.Name = price
newBtn.ImportantValues.AssetId.Value = item.id
newBtn.Parent = SignPrices
end)
end
end
return tshirts
end
local UrlB = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"
local function getUserCreatedGamepassesRecursive(userId, SignPrices, gamepasses, pageNumber, lastLength)
gamepasses = {}
pageNumber = pageNumber or 1
lastLength = lastLength or math.huge
local requestUrl = UrlB:format(pageNumber, userId)
local success, result = pcall(function()
return HttpService:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return HttpService:JSONDecode(result)
end)
if success2 then
if result2 then
for _, gamepass in ipairs(result2.Data.Items) do
if gamepass.Creator.Id == userId and table.find(gamepasses, gamepass.Item.AssetId) == nil then
table.insert(gamepasses, gamepass.Item.AssetId)
local e,s = pcall(function()
local newBtn = script.Template:Clone()
local price = gamepass.Product.PriceInRobux
newBtn.Name = price
newBtn.PurchaseButton.price.Text = "$"..price
newBtn.LayoutOrder = price
newBtn.ImportantValues.AssetId.Value = gamepass.Item.AssetId
newBtn.ImportantValues.AssetType.Value = "Gamepass"
newBtn.Parent = SignPrices
end)
end
end
else
warn(result)
getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
end
else
warn(result)
getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
return gamepasses
end
end
function AssetManager:GetAssets(Player, BoothUI)
getUserGeneratedTShirtsRecursive(Player.Name, BoothUI)
getUserCreatedGamepassesRecursive(Player.UserId, BoothUI)
end
return AssetManager
this is my button handler script:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local donationUI = playerGui:WaitForChild("donationUI")
local mainFrame = donationUI:WaitForChild("mainFrame")
local buttonsHolder = mainFrame:WaitForChild("buttonsHolder")
for _, Desc in pairs(buttonsHolder:GetDescendants()) do
if Desc:IsA("TextButton") and Desc.Parent:FindFirstChild("ImportantValues") then
Desc.MouseButton1Click:Connect(function()
if Desc.Parent.ImportantValues.AssetType.Value == "Clothing" then
MarketplaceService:PromptPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
elseif Desc.Parent.ImportantValues.AssetType.Value == "Gamepass" then
MarketplaceService:PromptGamePassPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
end
end)
end
end
buttonsHolder.DescendantAdded:Connect(function(Desc)
task.wait()
if Desc:IsA("TextButton") and Desc.Parent:FindFirstChild("ImportantValues") then
Desc.MouseButton1Click:Connect(function()
if Desc.Parent.ImportantValues.AssetType.Value == "Clothing" then
MarketplaceService:PromptPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
elseif Desc.Parent.ImportantValues.AssetType.Value == "Gamepass" then
MarketplaceService:PromptGamePassPurchase(player, Desc.Parent.ImportantValues.AssetId.Value)
end
end)
end
end)