Problem with Proccess Receipt[SOLVED]

So i tried to make Proccess Receipt but it don’t work idk why
I tried to change local function to function,change receiptInfo.PlayerId to receiptInfo.UserId and when player added connect function with line MarketplaceService.ProcessReceipt = proccessReceipt() but nothing changed error is still the same.
Error is in line 12: attempt to index nil with ‘PlayerId’ .
It is basic script.
Here is my script:

local MarketplaceService = game:GetService("MarketplaceService")
local PlayersService = game:GetService("Players")
local ReplicatedStorageService = game:GetService("ReplicatedStorage")

local BaseballBat = ReplicatedStorageService:WaitForChild("BaseballBat")

local productId = 1502344087



local function proccessReceipt(receiptInfo)
	local player = PlayersService:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if player then
		local BaseballBatClone = BaseballBat:Clone()
		local Backpack = player:WaitForChild("Backpack")
		BaseballBatClone.Parent = Backpack
		warn(player.Name.."just bought"..receiptInfo.ProductId)
	end
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
	
end
MarketplaceService.ProcessReceipt = proccessReceipt()

ReceiptInfo returns nil so it’s possible that you aren’t actually prompting the user to buy your product.

1 Like

Remove the brackets on this line:

MarketplaceService.ProcessReceipt = proccessReceipt
2 Likes

Thx, i was confused for a day.

Thx for try to help me. But i promted user.

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