Can't Prompt More Than Once After Input

I have a table that contains a bunch of Product Ids. When a player clicks a button. They get prompted with a purchase. Then, After they choose Ok>Ok, or Cancel, They get prompted with the next Product Id in the table. To do this, I am using a deprecated Event, but it just doesn’t matter.

The player gets prompted with the first product. Then, after they make their decision, the next prompt is an error that reads “Your purchase failed because something went wrong. Your account has not been charged. Please try again later.”

So, These are the important parts of my script.
Local Script

    local function promptPurchase()
    	if table.getn(AllItems)>0 then
    		local player = Players.LocalPlayer
    		local Variable = 0
    		for i,v in pairs(AllItems) do
    			MarketplaceService:PromptProductPurchase(player, v)
    			ReplicatedStorage.ProductsPurchasingEvent.OnClientEvent:Connect(function()
    				Variable = 1
    			end)
    			repeat wait() until Variable == 1
    			Variable = 0
    			wait(2)
    		end
    	end
    end
    script.Parent["Butttons/Data"].ImageButton.MouseButton1Click:Connect(promptPurchase)

ServerScript in ServerScriptService and the RemoteEvent is in Replicated Storage

local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MarketplaceService.PromptProductPurchaseFinished:Connect(function (player, assetid, OkCancel)
	local players = game:GetService("Players"):GetPlayerByUserId(player)
	ReplicatedStorage.ProductsPurchasingEvent:FireClient(players)
	return
end)

MarketplaceService.ProcessReceipt = processReceipt

How can I make it to where the player doesn’t have to click a different button for each product? Is it something ROBLOX has in place, or am I doing it wrong? Please help.

1 Like

I’ve seen a system like this before. Roblox does not have a multi-purchase system in place; you will have to perform successive purchasing like this.

Typically if a purchase can’t be made, it’ll prompt you the wrong asset. It won’t actually be a product from your game. If the prompt gives you the right product and you can buy it, it’s most likely an issue on Roblox’s end or a weird implementation detail in your code. Does non-successive purchasing work for you?

Thank you, I discovered that the problem is the assets. The script works. Its always the assets… always…