PromptPurchaseFinished
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
MarketplaceService/PromptGamePassPurchaseFinished
. - For developer product purchase prompts, connect to
MarketplaceService/PromptProductPurchaseFinished
. In order to process such purchases you need to set theMarketplaceService/ProcessReceipt|ProcessReceipt
callback in a single script.
Example
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)
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
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) |
Code Samples
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.