Product ID always returning nil


I was reading off the wiki about dev products because it was my first time using them, but every time I use my function in my server script and print the ID of the product it prints is nil.

Any help?


local MPS = game:GetService("MarketplaceService")

-- // Dev Products

	local ProdID = 314544711
	MPS:PromptProductPurchase(Player, ProdID)


local MPS = game:GetService("MarketplaceService")

function MPS.ProcessReceipt(receiptInfo)
	print(receiptInfo.ProdID) -- // Where it prints nil
	return Enum.ProductPurchaseDecision.PurchaseGranted


have you tried printing receiptInfo.ProductId instead of receiptInfo.ProdID ?


Still returns nil, not even an error


Double-check you’re spelling it correctly. Here’s all the keys that should exist in the receiptInfo. I’ve never had it print nil before. Notice the “d” in “Id” is lowercase.

Also, you can double-check by listing all contents of receiptInfo:

for k,v in pairs(receiptInfo) do print(k,v) end


This worked, but its not clear on the wiki. In my mind I thought logically that I would print the variable not ProductId


When you access a table using a key, it will always return the value. If you’re new to tables, I would recommend looking at some tutorials for them. They can be a tricky concept to pick up.


Also just another quick question, how would I access the players stats in the server script? I tried

function MPS.ProcessReceipt(Player, receiptInfo)

but it doesn’t seem to work.


local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)


This should help you plenty

It has DevProduct Script and a Lesson about Tables.