Product ID always returning nil


#1

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

#2

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


#3

Still returns nil, not even an error


#4

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

#5

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


#6

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.


#7

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.


#8

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


#9

This should help you plenty

It has DevProduct Script and a Lesson about Tables.