How could this be more efficient, sometimes it does not give them cash.
local Products={ ["0"]=100, --Hidden ["0"]=200, --Hidden ["0"]=300, --Hidden ["0"]=400, --Hidden ["0"]=500, --Hidden } Game:GetService("MarketplaceService").ProcessReceipt=function(Receipt) local PlayerProductKey = Receipt.PlayerId.."_"..Receipt.PurchaseId for _,Player in ipairs(Game.Players:GetChildren())do for i, v in pairs(Products)do if tostring(Receipt.ProductId)==i then repeat wait(2) until Player:FindFirstChild("leaderstats") Player:FindFirstChild("leaderstats").CashPLAYER.Value = Player:FindFirstChild("leaderstats").CashPLAYER.Value + v Game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(PlayerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end end end end
Look here https://scriptinghelpers.org/blog/developer-products-in-app-purchases-in-roblox