I'm trying to use this same script for other Developer Products. If I use this script more than once, the Marketplace Service won't work. Any help on how to fix this?
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
print("Testing Receipt Loaded")
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId --Should I change this manually with something?
local numberBought = ds:IncrementAsync(playerProductKey, 1)
for i,v in pairs (game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == 19918045 then
print("Did this succeed?")
lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
cs = lds:FindFirstChild("Coins")
if cs ~= nil then
cs.Value = cs.Value + 100
print("Coins Sent")
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
