local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync(playerProductKey) then return Enum.ProductPurchaseDecision.PurchaseGranted end for i, plr in ipairs(game.Players:GetPlayers()) do if plr.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == id then plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value +1000 end end end PurchaseHistory:SetAsync(playerProductKey, true) return Enum.ProductPurchaseDecision.PurchaseGranted end
I didn't code this, I've been messing around with a code from the wiki; http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService
I know what it does and what it should do.
When I buy the DevProduct, it shows in console(f9) Cannot access DataStore from this client.
Does anyone know a solution?
Screenshot of error: http://prntscr.com/88yisp
You should be handling purchases and data store related tasks server-side (not using a LocalScript) -- as mentioned in the article you've got your code from. If you need to communicate the result of your work to the client, you can use a RemoteObject to do so.