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)
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.
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.
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!