Failed to process receipt: attempt to call a nil value

So I am currently making dev products in my game.
Where I run into this error.

Failed to process recipt:  ▶ {...} attempt to call a nil value

I dont know why this is happening. So if you could help that would be amazing! Thanks :smiley:


Give rewards.

productFunctions[1539404003] = function(recipt,player) -- 300 gems
	local profile = player.Profile

	if profile then
		local gems = profile.Gems

		gems += 300
		return true
	end
end

Handle the receipt.

local function handleRecipt(info) -- handle receipts!
	warn('Loading receipt')
	local ID = info.PlayerId
	local ProductID = info.ProductId
	
	local player = game:GetService('Players'):GetPlayerByUserId(ID)
	
	if player then
		local handler = productFunctions[ID]
		local success, result = pcall(handler,info, player)
		
		if success then
			warn('Loaded recipt success!')
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn('Failed to process recipt:',info,result)
		end
	end
end

mps.ProcessReceipt = handleRecipt

A minor typo? ProductID?

Also, don’t forget about Enum.ProductPurchaseDecision.NotProcessedYet. (Developer Products | Roblox Creator Documentation)

1 Like

Yeah that was a typo!
Thank you lol

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.