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)
As I have stated in the comment on DeSpizer MouseButton1Click does not return a player in PlayerGui. You turned something that was designed in a free model from SurfaceGui to ScreenGui, so the events and functions don't work the same way.
id = 20518668 --dev product id script.Parent.MouseButton1Click:connect(function() p = script.Parent.Parent.Parent.Parent.Parent game:GetService("MarketplaceService"):PromptProductPurchase(p.userId, 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)
And we do advise against having multiple questions here (though there should be a bump system for after a day, you can bring your question to the front again unless it's locked).
Also, it does help if you explain the situation in detail, if you hadn't posted your error, I would not know how to solve your problem.
Try this;
ds = game:service'DataStoreService' id = 20518668 --dev product id script.Parent.MouseButton1Click:connect(function(p) game:GetService("MarketplaceService"):PromptProductPurchase(p.userId, 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)
Marked as Duplicate by SanityMan, TheeDeathCaster, M39a9am3R, and adark
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?