I'm using the example code from the PromptPurchaseFinished wiki page and I can't get it to function correctly. I feel like I may be missing something simple. I tried opening my active game from Studio and creating a new server script under ServerScriptService with the following code. When I step through it, nothing is printed. It just goes from line 5 to 11:
local MarketplaceService = game:GetService("MarketplaceService")
local assetId = 1241982351
local player = "SuperDragonHunter64"
local isPurchased = nil
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)

4 comments
I tried that and it's the same result. Wouldn't it need those to be defined though? Especially assetId? Otherwise it wouldn't know what asset to check.
Not necessarily, because the event will fire when any gamepass is bought, I changed my answer so you can understand it more.
Ok, thank you. I understand now. The code you have listed does work. Once I make an in game purchase using PromptPurchase, the function you have above listens for any purchase made and returns the player, assetId, and if it was purchased.
You're welcome! Please accept this answer if it works.