Let's say I prompted a purchase in my game, and when the purchase is finished, whether they bought it or not, I want the gui to disappear. How would I do that?
To achieve this, you can use the PromptPurchaseFinished
event of the MarketplaceService
.
Example:
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)
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.