I have got this but it wont work
id = 20518668 --dev product id
script.Parent.MouseButton1Click:connect(function(p)
game:GetService("MarketplaceService"):PromptProductPurchase(p, id)
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
if p.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == id then
p.leaderstats.Cash.Value = p.leaderstats.Cash.Value + 5000
end
end
-- record the transaction in a Data Store
local playerProductKey = receiptInfo.PlayerId .. "_got_" .. receiptInfo.PurchaseId
ds:IncrementAsync(playerProductKey, 1)
-- tell ROBLOX that we have successfully handled the transaction
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end)

2 comments
Be patient. You have already posted this twice: https://scriptinghelpers.org/questions/8375/how-do-i-add-ingame-cash-when-clicking-a-gui-still-not-working and https://scriptinghelpers.org/questions/8382/why-wont-this-work-please-help
It's because no one is even looking at the first ones.