Server Script
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local gun = ReplicatedStorage:WaitForChild("Handgun")
local players = game:GetService("Players")
local receiptInfo = ga
local productId = 986593881
local function proccessReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
--the player probably left the game
--if they come back, the callback will be recalled
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
-- what do you want the dev product to do
local char = game.Workspace:FindFirstChild(player.Name)
local gunClone = gun:Clone()
gunClone.Name = "Gun"
gunClone.Parent = char
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
--set callback
MarketplaceService.ProcessReceipt = proccessReceipt()
My local script
local MarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local productId = 986593881
local player = game.Players.LocalPlayer
wait(3)
MarketplaceService:PromptProductPurchase(player, productId)
I am getting an error 16:19:56.739 - ServerScriptService.Script:10: attempt to index nil with 'PlayerId' and I am not getting the item, why?
