I tried to mix 2 Devproducthandler but the rewards got multiply every purchase plss help
---//DEV RECEIPT\\---
--//MAIN
MarketplaceService.ProcessReceipt = function(receiptInfo)
--//LOCALS
--//PART 1
local Success, Error = pcall(function()
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
local amount = Products[receiptInfo.ProductId]
player.leaderstats.Donated.Value = player.leaderstats.Donated.Value + amount
player.playerstats.Dpoints.Value = player.playerstats.Dpoints.Value + amount
end)
--//PART 2
local plrId = receiptInfo.PlayerId
local purchasedId = receiptInfo.ProductId
for i, pass in pairs(gamepasses) do
local passId = pass[1]
local productId = pass[2]
if purchasedId == productId then
local giftUserId = playersGifted[plrId]
if giftUserId then
playersGifted[plrId] = nil
local success, err = pcall(function()
giftedData:SetAsync(giftUserId .. "-" .. passId, true)
end)
if success then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end
end

1 comment
Can you do it for me? I'm still new and not familiar with other things such as pcall