Doing something after the player buys a Developer Product

I made a Developer Product to give players money in-game when they buy it, the prompt purchase itself already works, but i can’t seem to figure it out how to make it so they actually get the money when they buy it.

I already read this article but i don’t understand it so that’s why i am asking in the devforums.

This is my code:

local mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local plr = players.LocalPlayer
local did = 1127166407

script.Parent.MouseButton1Click:Connect(function()
	mps:PromptProductPurchase(plr, did)
end)
local mps = game:GetService("MarketplaceService")
local did = 1127166407

script.Parent.MouseButton1Click:Connect(function(click)
    local players = game:GetService("Players")
    local plr = players:GetPlayerFromCharacter(click)
	mps:PromptProductPurchase(plr, did)
end)

Your just missing the reference to who clicks the button.

local mps = game:GetService("MarketplaceService")
local did = 1127166407
local Owns =false

script.Parent.MouseButton1Click:Connect(function(click)
    local players = game:GetService("Players")
    local plr = players:GetPlayerFromCharacter(click)
	mps:PromptProductPurchase(plr, did)
    Owns = true
    if Owns == true then
     -- Your Reward
     end
end)

Here is the Developer Product Version.

This could help ProcessReceipt, DM me if you need help.

I think if i use that code, it wouldn’t necessarily work, because i don’t think you’re detecting when the DevProduct is being bought, i think that it would just pop up on screen and just give the reward instantly, instead of the player needing to buy it

1 Like

Sorry, I can’t help as much but maybe follow what @luketeam5 posted, maybe it can help.