Problem with making something happen when a dev product is purchased

I have a dev product and I want something to happen when someone buys it, I searched up MarketplaceService in the api and found some functions that I thought would help me do that. This is my script so far:

local MarketPlaceService = game:GetService("MarketplaceService")

MarketPlaceService.PromptPurchaseFinished:Connect(function(Player, Id)
    if MarketPlaceService:PlayerOwnsAsset(Player, Id) then
       print("A player just bought something!")
    end
end)

But when I playtest and buy said dev product it doesn’t print anything, no errors either.

1 Like

Did You Make Sure that you really did make a purchase

It actually did say it was a test purchase and it wouldn’t charge me when I bought it, maybe that’s why it didn’t work

How can I buy it without it being a test purchase?

Here MarketplaceService | Documentation - Roblox Creator Hub
RBXScriptSignal PromptPurchaseFinished ( Instance player , int64 assetId , bool isPurchased ) Fires when a purchase prompt closes for an affiliate gear sale or other asset (does not fire for developer product or game pass prompts)

1 Like

no

30char

why are you checking that they own an asset

you should use

MarketplaceService:UserOwnsGamepassAsync()

Ah, should have read it more carefully.

That would require a while loop, and I’d rather not because it’s bad for performance. Also it’s a dev product not a gamepass

Also here are some video to help :slight_smile:

1 Like

Please do not use any prompt finished API for doing this and please search before posting threads. You should have searched up “developer products” instead of MarketplaceService’s API first: there are articles available for showing you how to handle developer products.

If you aren’t trying to handle a purchase and just to show something visually or otherwise, then ignore this and continue on with using the prompt event.

1 Like