Look I have a problem, when I buy money once they are credited to the player, when the second time I buy then nothing happens, that is, the money to the player is not credited but at the same time the purchase is successful in what could be the problem?
local MarketplaceService = game:GetService("MarketplaceService")
local DatastoreService = game:GetService("DataStoreService")
local PreviousPurchases = DatastoreService:GetDataStore("PreviousPurchases")
local productFunctions = {}
local cash5000 = 1823229791 -- 5000 cash id --
local cash15000 = 1823230874 -- 15000 cash id --
local cash50000 = 1823230999 -- 50000 cash id --
local function giveCash(plr, amt)
wait(1)
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + amt
game.ServerStorage:WaitForChild("PlayerMoney"):FindFirstChild(plr.Name).Value = game.ServerStorage:WaitForChild("PlayerMoney"):FindFirstChild(plr.Name).Value + amt
end
productFunctions[cash5000] = function(info, plr) -- gives plr 5000 cash
giveCash(plr, 5000)
end
productFunctions[cash15000] = function(info, plr) -- gives plr 15000 cash
giveCash(plr, 15000)
end
productFunctions[cash50000] = function(info, plr) -- gives plr 50000 cash
giveCash(plr, 50000)
end
local function procRec(reciept)
local ID = reciept.PlayerId.."-"..reciept.PurchaseId
if PreviousPurchases:GetAsync(ID) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(reciept.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
local handler = productFunctions[reciept.ProductId]
local s, e = pcall(function()
handler(reciept, player)
end)
if s then print("supposedly went through") return Enum.ProductPurchaseDesicion.PurchaseGranted elseif not s then warn(e) return Enum.ProductPurchaseDecision.NotProcessedYet end
end
MarketplaceService.ProcessReceipt = procRec
No there are no other scripts, no errors, the first time the purchase passes and the money is credited to the leaderboard, the second time I buy the purchase passes the money is not there.