Hey, I am trying to make a script which processes a Developer product. Now, the purchasing works, but the script does not trigger. I don't get errors either.
local market = game:GetService("MarketplaceService") local Https = game:GetService("HttpService") local function processreceipt(receiptInfo) print("received it") local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) local id = receiptInfo.ProductId if not plr then return Enum.ProductPurchaseDecision.NotProcessedYet else print("Purchased!" return Enum.ProductPurchaseDecision.PurchaseGranted end end market.ProcessReceipt = processreceipt
It does not print "received it".
Here's some code from the official Roblox page that I edited to work, change the ID to whatever dev purchase happens and change what it does below the 'then'. You can add more of them if needed I haven't tested it yet.
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local function getPlayerByUserId(userId) for _, player in pairs(Players:GetPlayers()) do if player.UserId == userId then return player end end end local function processReceipt(receiptInfo) -- Find the player who made the purchase in the server local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- The player probably left the game -- If they come back, the callback will be called again return Enum.ProductPurchaseDecision.NotProcessedYet end -- Output what product they bought if receiptInfo.ProductId == 940739628 then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 50 else print("do nothing") end print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId) -- IMPORTANT: Tell Roblox that the game successfully handled the purchase return Enum.ProductPurchaseDecision.PurchaseGranted end -- Set the callback (this can only be done once by one script on the server!) MarketplaceService.ProcessReceipt = processReceipt
Please accept if this solves your problem. If you have any questions please feel free to ask in the comments.