How do I detect when a prompt purchase is finished?

local id = script.Parent.ProductId.Value
local remote = game.ReplicatedStorage.ForwardVibez
local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer


So I’m trying to make it so when you buy a certain product, it gives you currency.
But I am quite stuck on what to use, I don’t know how to wait until a purchase is finished.

Can anyone help?

You can utilize PromptPurchaseFinished to detect this. Its documentation can be found here.

Edit: If you’re selling a Developer Product, however, you’d use PromptProductPurchaseFinished (even though it’s deprecated)


This happens.


Whenever I try using the right syntax. (I’m using a gui to buy the currency and the last paramter is a bool but it won’t let me up true?)

The third parameter shouldn’t be the word “true” since the value that the function returns for the third parameter could be true or false.

Instead, you could change it to something else such as “didPlayerPurchase” and you could print its value in the function to see if they purchased the item, cancelled it, etc…

mps.PromptProductPurchaseFinished:Connect(function(userId, productId, didPlayerPurchase)
    print(didPlayerPurchase) -- This will be true or false