A DataStore2 Problem

I’m having this problem when a player buys a developer product and the DataStore2 module increments double each time you purchase.

Example: the first time I buy a 100 Cash product and get 100
the second time I buy a 100 Cash product and get 200

it keeps on doubling each purchase.


Product Manager:

local MPS = game:GetService("MarketplaceService")
local DataStore2 = require(1936396537)

local Products = {
	[100] = 1273371645,
	[300] = 1273371646,
	[500] = 1273371644,
	[800] = 1273371643,
MPS.ProcessReceipt = function(receiptInfo)
	local Player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	local SpeedDataStore = DataStore2("Speed", Player)
	if receiptInfo.ProductId == 1273371645 then
		SpeedDataStore:Increment(100, 0)
	elseif receiptInfo.ProductId == 1273371646 then
		SpeedDataStore:Increment(300, 0)
	elseif receiptInfo.ProductId == 1273371644 then
		SpeedDataStore:Increment(500, 0)
	elseif receiptInfo.ProductId == 1273371643 then
		SpeedDataStore:Increment(800, 0)

and the buy script:

local Products = require(script.Parent.Parent.Parent.Parent.Parent.Products)
local Player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")

	MPS:PromptProductPurchase(Player, Products[100])

How could i fix this?

1 Like

i suspect the issue is with the module script you required with an id. Show the Increment method’s code.

MarketplaceService.ProcessReceipt will keep calling your function until the function returns Enum.ProductPurchaseDecision.PurchaseGranted, so you have to return the enum if the purchase is correct.


This likely isn’t a DS2 issue, rather an issue with the purchasing system, as mentioned in the comment above!