I need help with a developer product

I want to make a dev product that gives the player 100 Clicks.

It gives the player the correct ammount of Clicks, but then it adds 200 at the next purchase.

I tried lots of other things, but haven’t found anything that works.

local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local asset = 1156130202
clicks = 100

	mps:PromptProductPurchase(plr, asset)
	mps.PromptProductPurchaseFinished:Connect(function(plr, asset, purchased)
		if purchased then

(This is my first post, sorry if I got anything wrong.)

Whats the Script receiving the remote look like?

	plr.leaderstats.Clicks.Value = plr.leaderstats.Clicks.Value + clicks

So when you buy it once, your cash goes to 100, but you buy it again and your cash becomes 200?

no, it gains 200 the next time.

I think he means, it gives 200 more after

So it becomes 300, is that correct

Yeah, it gains 100, then gains 200, than gains 300.

1 Like

so in increments of 100.
Ok. in the “Else” statements, try adding ‘return’ instead of nothing

robloxapp-20210306-1606161.wmv (536.7 KB)

Each time you click the button, you create a new PromptProductPurchaseFinished listener. So on the next one you would get 300, then 400, then so on. PromptProductPurchaseFinished is deprecated anyway, so you should set MarketplaceService.ProcessReceipt on the server.

So your client code becomes

-- improved some readability/consistency
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local asset = 1156130202

-- Activated is preferred over MouseButton1Click
	mps:PromptProductPurchase(player, asset)

Then in a server script you want to set MarketplaceService.ProcessReceipt.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

function MarketplaceService.ProcessReceipt(receipt)
	local player = Players:GetPlayerByUserId(receipt.PlayerId) -- player id is user id

	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet -- maybe left or something

	if receipt.ProductId == 1156130202 then
		player.leaderstats.Clicks.Value += 100
	return Enum.ProductPurchaseDecision.PurchaseGranted

Learn more here

1 Like