Developer Product Currency that is Given Gets Multiplied Each Purchase

So I made a donation leaderboard blah blah blah. But there seems to be a problem with the rewarded currency after purchased via Developer Product.

This is what happens:


(I Sped the video up so it fits with the dev forum size limit.

I’m 100% sure that it is my code.

local mps = game:GetService("MarketplaceService")
local Donation1 = 1156345779
local Donation2 = 1156345978
local Donation3 = 1156345885
local Donation4 = 1156346100
local Donation5 = 1156346173
local Donation6 = 1156346306

local function processReceipt(receiptInfo)

  local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
  if not player then
    return Enum.ProductPurchaseDecision.NotProcessedYet
  end

  if player then
    if receiptInfo.ProductId == Donation1 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 25
    elseif receiptInfo.ProductId == Donation2 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 100
    elseif receiptInfo.ProductId == Donation3 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 500
    elseif receiptInfo.ProductId == Donation4 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 1000
    elseif receiptInfo.ProductId == Donation5 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 5000
    elseif receiptInfo.ProductId == Donation6 then
      player.RobuxInfo.RobuxDonated.Value = player.RobuxInfo.RobuxDonated.Value + 10000
  end
end
end

mps.ProcessReceipt = processReceipt

If you have any idea why It multiplies each purchase. Then please leave it down in the replies. Thanks.

1 Like

It could be the way you did your code, after the if player end statement, do

return Enum.ProductPurchaseDecision.PurchaseGranted

There’s nothign that tells the ProcessReceipt that the purchase was granted or not

1 Like

Thanks so much! I really forgot to do that xD

It’s fine, obvious mistakes can happen sometimes, and they can be ignored by our brains when we’re trying to figure out the issue, it’s good that you came here to ask for help, it helps get fresh pair of eyes to see your code to see the issue, which is what happened.

I’m glad to hae helped you with your issue! If you have anymore issues don’t be afraid to make another post!

2 Likes