Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making a dev product but it dosen't work? Closed (Reason: To hard lol)

So i made a dev product (UI) but i can't get "ProcessReceipt" in a local script so i so i used a remote event but it says

"Receipt info a nil value" (in regular script)

and i don't know how to fix it

script in workspace (regular) btw. code: (script in worksace) V

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()

local market = game:GetService("MarketplaceService")

  

  

function market:ProcessReceipt(ReceiptInfo)

local player = game.Players:GetPlayerByUserId(ReceiptInfo.PlayerId)

if ReceiptInfo.ProductId == 12345 then

player.Character.Humanoid.WalkSpeed = 50

end

end

end)

local script under text button (remote event in ReplicatedStorage) btw.

local Player = game.Players.LocalPlayer

    local id = 12345
    
    local market = game:GetService("MarketplaceService")
    
    local rem = game.ReplicatedStorage.RemoteEvent
    
      
    
    script.parent.TextButton.MouseButton1Click:Connect(function()
    
    market:PromptProductPurchase(Player,id)
    
    game.ReplicatedStorage.RemoteEvent:FireServer()
    
    end)

2 comments

0

Why on earth are you making a method of the same name as the MarketplaceService's callback? That literally makes no sense.

0

It's just odd to assign to a service's property; this is the only time I know of where it's the correct api use. Pretty sure this syntax is valid unless it's expecting no self internally.

1 answer

Your first problem is that the MarketplaceService.ProcessReceipt assignment happens inside a RemoteEvent callback.

From the ProcessReceipt page, in bright yellow:

As with all callbacks, this function should be set once and only once by a single [Script](https://developer.roblox.com/api-reference/class/Script). If you're selling multiple products in your game, this callback must handle receipts for all of them.

then again in the sample code:

-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt

The possible second problem is the syntax you used. The example is assigned with a dot notation; not a colon.

local function processReceipt(receiptInfo)
	-- do what you need with receiptInfo
end

MarketplaceService.ProcessReceipt = processReceipt

This discussion is preserved as it was. New answers, comments, and votes are closed.