To achieve this, you can use the PromptPurchaseFinished
event of the MarketplaceService
.
Example:
1 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
3 | MarketplaceService.PromptPurchaseFinished:Connect( function (player, assetId, isPurchased) |
5 | print (player.Name .. " bought an item with AssetID: " .. assetId) |
7 | print (player.Name .. " didn't buy an item with AssetID: " .. assetId) |
If you want the GUI to disappear regardless of whether a purchase was made or not, then you can get rid of the if-statements and just set the GUI Enabled
property to false in the function.