Ok my script looks like this and it is supposed to add 100 money to the leaderstats after somebody buys the developers product but its not working
local MarketplaceService = game:GetService("MarketplaceService") local MoneyID = 20805766 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 --We already granted it. end -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product) if receiptInfo.ProductId == MoneyID then -- handle purchase. In this instance we're giving the player 100 extra gold. player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 end end end -- record the transaction in a Data Store PurchaseHistory:SetAsync(playerProductKey, true) -- tell ROBLOX that we have successfully handled the transaction (required) return Enum.ProductPurchaseDecision.PurchaseGranted end

1 comment
Please use the lua code block format when posting a script.