I'm making a script that when a person buys a gamepass/devproduct, it will fire an event in the replicated storage. But, it appears that the Marketplace.ProcessReceipt event never occurs when I perform a test purchase in studio. Here is my code. What could be the issue?
local MarketplaceService = game:GetService("MarketplaceService") local Events = game.ReplicatedStorage.Marketplace local Players = game:GetService("Players") local Events = { [39145813] = Events.Backpack.Backpack20Slots } local function processReceipt(receiptInfo) print("TEST") -- does not print and the lines of code below dont do anything local player = Players:GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- player does not exist / left game? return Enum.ProductPurchaseDecision.NotProcessedYet end print(player.Name.." just purchased "..receiptInfo.ProductId) for id,event in pairs(Events) do if id == receiptInfo.ProductId then event:Fire(player, id) -- id parameter isn't always used in other scripts (this is mainly for when effects are bought) print("Event Fired for"..id) return Enum.ProductPurchaseDecision.PurchaseGranted end end end MarketplaceService.ProcessReceipt = processReceipt
Im not the best but i think you might of not put the ID here
local MarketplaceService = game:GetService("MarketplaceService") local Events = game.ReplicatedStorage.Marketplace local Players = game:GetService("Players") local Events = { [39145813] = Events.Backpack.Backpack20Slots } local function processReceipt(receiptInfo) print("TEST") -- does not print and the lines of code below dont do anything local player = Players:GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- player does not exist / left game? return Enum.ProductPurchaseDecision.NotProcessedYet end print(player.Name.." just purchased "..receiptInfo.ProductId) for id,event in pairs(Events) do if id == receiptInfo.ProductId then event:Fire(player, ID HERE) -- I dont think it will work but let me know print("Event Fired for"..id) return Enum.ProductPurchaseDecision.PurchaseGranted end end end MarketplaceService.ProcessReceipt = processReceipt