PromptPurchaseFinished fires when a purchase dialogue of an affiliate gear sale or other asset is closed. This fires right as the dialogue closes when the player presses “Cancel” at the prompt, or “OK” at the success/error message.
- For game passes, use
- For developer product purchase prompts, connect to
MarketplaceService/PromptProductPurchaseFinished. In order to process such purchases you need to set the
MarketplaceService/ProcessReceipt|ProcessReceiptcallback in a single script.
Below is a screenshot of an affiliate gear sale prompt. The function in the code sample runs immediately after the player presses “Cancel” or after the user buys the item then presses “OK”. Should there be an issue with the purchase, the event also fires.
local MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.PromptPurchaseFinished:connect(function (...) -- Print all the details of the prompt, for example: -- PromptPurchaseFinished PlayerName 11377306 true print("PromptPurchaseFinished", ...) end)
The Player object for whom the prompt was shown
The asset ID number of the item shown in the prompt
Whether the item was successfully purchased (false for errors and cancellations)
Handling PromptPurchaseFinished Event
The below example would print ‘Telamon bought an item with AssetID: 1111’ to the output, if they were to complete a transaction in (your) game with an item that had an AssetID of 1111. Alternatively, it would print ‘Telamon didn’t buy an item with AssetID: 1111’ if the opposite was true.
local MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased) if isPurchased then print(player.Name .. " bought an item with AssetID: " .. assetId) else print(player.Name .. " didn't buy an item with AssetID: " .. assetId) end end)