Fake attempt to call a boolean value?

I have this script that gives the player 50 coins when buying a product, although everything works fine, why am I getting the following error (warn)? (PRODUCT_ID is specified, I just not included it)
Failed to process receipt: :arrow_forward: {…} attempt to call a boolean value

Script:

productFunctions[PRODUCT_ID] = function(receipt, player)
	local playerInfo = player:FindFirstChild("PlayerInfo")
	local coins = playerInfo and playerInfo.Values.Coins
	if coins then
		GaMe.addCoins(player,50)
		return true
	end
end

local function processReceipt(receiptInfo)
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if player then
		local handler = productFunctions[productId](receiptInfo,player)
		local success, result = pcall(handler, receiptInfo, player)
		if success then
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Failed to process receipt:", receiptInfo, result) -- outputted thing
		end
	end
	return Enum.ProductPurchaseDecision.NotProcessedYet
end

It’s because you’re immediately calling handler and passing the result of it into the pcall, your local handler line should be

local handler = productFunctions[productId]

So it can be ran in the pcall

1 Like

I was using that before, and for some reason (that I forgot) it didn’t work. It warned another thing. And now… it works? What the heck is this function

1 Like