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()