Attempt to prompt multiple assets only prompts one?

Hello! Recently, I have been writing a script where you can put items into a “shopping cart” and then press checkout, where it will do a prompt purchase for all the items.

The main problem is that it only seems to be prompting one asset. When I do prints, it says I bought all three (assuming I put all 3 in the cart) even though I could only view one prompt. Is there any way I can fix this?

I have attempted to use debounce and PromptPurchaseFinish but it still doesn’t seem to work.

local market = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
    for a, b in pairs(script.Parent.Parent.Items:GetDescendants()) do
        if b:IsA("NumberValue") and b.Name == "AssetId" then
            market:PromptPurchase(game.Players.LocalPlayer, b.Value)
            market.PromptPurchaseFinished:Wait()
        end
    end
end)
2 Likes

You shouldn’t need to use repeat wait() until. Just use the market.PromptPurchaseFinished:Wait()

Apart from this, I’m not too sure. When you used print() for debugging, where did you put it and did all 3 print at once?

1 Like

I just tested this right now and got the same result. I put the print after the
market.PromptPurchaseFinished:Wait() and if I click cancel on the purchase, it only printed once. When I clicked buy, it would print however many items were in the cart.

2 Likes

What could be happening is that when you click the buy button, Roblox is bringing up the next one instantly, while your mouse button is still down in the correct position. This is purely speculation, but try putting a wait(1) after the market.PromptPurchaseFinished:Wait() for debugging. if this works you can reduce the wait time.

3 Likes

Purchase prompts have a slight delay before they can be shown again, this is to prevent scamming etc.
(The delay varies I believe.)

You also can’t have 2 prompts show up at the same time.

3 Likes

This solution worked. I appreciate the help @AstonAceMan and @OutlookG . Thank you!

2 Likes

No worries, I think @OutlookG was correct, and it just happened to be that by solution for a different problem also worked with the issue OutlookG identified. Good luck with your project!

2 Likes