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?

Client:

local MPS = game:GetService("MarketplaceService")

-- // Dev Products

script.Parent.Product1.TextButton.MouseButton1Click:Connect(function()
	local ProdID = 314544711
	MPS:PromptProductPurchase(Player, ProdID)
end)

Server:

local MPS = game:GetService("MarketplaceService")

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

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

2 Likes

Still returns nil, not even an error

1 Like

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:

print("ReceiptInfo:")
for k,v in pairs(receiptInfo) do print(k,v) end
3 Likes

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

1 Like

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.

2 Likes

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.

1 Like

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

3 Likes

This should help you plenty

It has DevProduct Script and a Lesson about Tables.

2 Likes