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)
Don't define player, isPurchased, or assetId. (Lines 02 - 04)
local MarketplaceService = game:GetService("MarketplaceService") myId = 1337 MarketplaceService.PromptPurchaseFinished:connect(function(player, assetId, isPurchased) if assetId == myId then 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 else print("they didnt buy my id!") end end)
Try that code instead.