Problems with script, I would like help

I’m having difficulty with this script. When the player clicks on the button to purchase the Item, the purchase fails. Any idea what it could be?

local HttpService = game:GetService("HttpService");
local MarketplaceService = game:GetService("MarketplaceService");
local Player = game:GetService("Players")
--
local URL = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorType=2&IncludeNotForSale=true&Limit=30&CreatorTargetId=15176463"
local response = HttpService:GetAsync(URL)
local decodedData = HttpService:JSONDecode(response)
--
task.spawn(function()
	if decodedData and type(decodedData) == "table" then
		if decodedData.data and type(decodedData.data) == "table" then
			local idsTable = {} 
			--
			for _, item in ipairs(decodedData.data) do
				if type(item) == "table" and item.id then
					table.insert(idsTable, item.id)
				end
			end
			--
			for _, Button in pairs(script.Parent.Content.ScrollingFrame:GetChildren()) do
				if Button:IsA("ImageButton") then
					Button:Destroy();
				end
			end
			
			for i, ItemId in ipairs(idsTable) do
				local NewTemplate = script.Template:Clone()
				NewTemplate.Parent = script.Parent.Content.ScrollingFrame
				NewTemplate.Thumbnail.Image = "https://www.roblox.com/asset-thumbnail/image?assetId="..ItemId.."&width=420&height=420&format=png"
				--
				task.spawn(function()
					local Details = nil
					local success, err = pcall(function()
						Details = MarketplaceService:GetProductInfo(ItemId, Enum.InfoType.Asset)
						NewTemplate.PriceLabel.Text.Text = Details.PriceInRobux or "Offsale"
						local ItemName = Details.Name  
						NewTemplate.NameItem.Text = ItemName
						--
						NewTemplate.MouseButton1Click:Connect(function()
							MarketplaceService:PromptPurchase(ItemId);
						end)
						--
						if MarketplaceService:PlayerOwnsAsset(Player, Details) then
							NewTemplate.PriceLabel.Text.Text = "Owned"
						else
							NewTemplate.PriceLabel.Text.Text = Details.PriceInRobux or "Offsale"
						end
						--
						MarketplaceService.PromptPurchaseFinished:Connect(function(Player, ItemId, isPurchased)
							if Player == Player and ItemId == ItemId and isPurchased then
								NewTemplate.PriceLabel.Text.Text = "Owned"
							end
						end)
					end)
				end)
				
			end
		end
	end
end)

Using the same topic. Is it possible to add some function to go to the next page when the limit of 30 reaches?

1 Like

make sure your not using roproxy, there are many other solutions to this