Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This DeveloperProduct script is not working, it increases every time you buy it?

local mServ = game:GetService("MarketplaceService")

local empoint100 = 266986370
local empoint1000 = 266985735
local empoint10000 = 266986634
local empoint2000 = 266985880
local empoint3000 = 266986118
local empoint5000 = 266986765

mServ.ProcessReceipt = function(receiptInfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == empoint100 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 100
			elseif receiptInfo.ProductId == empoint1000 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 1000
			elseif receiptInfo.ProductId == empoint10000 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 10000
			elseif receiptInfo.ProductId == empoint2000 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 2000
			elseif receiptInfo.ProductId == empoint3000 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 3000
			elseif receiptInfo.ProductId == empoint5000 then
				player.leaderstats.EmPoints.Value = player.leaderstats.EmPoints.Value + 5000
			end
		end
	end
end

When I purchase 10,000 EmPoints for the first time it works, but the second and third time the amount it gives is increased by 10,000.

Any help would be appreciated, thanks!

1 answer

✓ Accepted answer

Unlike a game pass a developer product is not owned by the player so there is now way to know who has what sales. ProcessReceipt requiores you to pass back if the sale was processed successfully ie has the ingame items been added correctly.

If an item is not processed successfully then this funcion will be called again until the successful state is returned.

Example:-

mServ.ProcessReceipt = function(receiptInfo)

	if receiptInfo.ProductId == 266986370then
		-- give points save data ect
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end

	return Enum.ProductPurchaseDecision.NotProcessedYet
end

I hope this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.