I am trying to make a credit shop, and when they buy the dev. product it adds 10 credits to their value When I buy the product it doubles the amount that I already have (ex. I start with 110, and buy it now I have 220... I should only be getting ten)
Heres the script :
local player = game.Players.LocalPlayer
local cash = game.Players.LocalPlayer.Cash
function CompletePurchase()
wait(1)
player.Cash.Value = player.Cash.Value + 10
end
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 23429504
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == productId then
CompletePurchase()
end
end
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
There is also another script :
local buy = script.Parent
local productId = 23429504
buy.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

5 comments
This code shows no reason as to why you would be getting the explained bug, do you have other scripts that are tied to ProcessReceipt? Or is it just a coincidence, like you're naturally gaining 100 right when you buy the Developer Product?
Can you edit your answer to display the script that Prompts the purchase please?
Added.
I'm sorry, I have no idea why your code would be reacting this way - there's no reason for it to. But the thing is that i've heard of people having this bug before so it might be an actual bug. You should check and make sure that there's nothing else defining the ProcessReceipt in your game.
Do you have anything cloning either of these scripts, or are they just in a backpack or playergui? If the scripts are getting cloned (specifically, getting cloned every time a purchase occurs), perhaps that might explain why the function is getting run multiple times.