I’m trying to create a developer product. The following is a server script that I used to award the player with items upon buying it.
local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
if not game.Players:GetPlayerByUserId(receiptInfo.ProductId) then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receiptInfo.ProductId == 123123 then -- our product id
print('works')
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
This same script has worked for me previously, and has stopped working. Any idea what’s going on?
local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local Return = nil
if not game.Players:GetPlayerByUserId(receiptInfo.ProductId) then
Return = Enum.ProductPurchaseDecision.NotProcessedYet
else
if receiptInfo.ProductId == 123123 then -- our product id
print('works')
Return = Enum.ProductPurchaseDecision.PurchaseGranted
end
end
if Return == nil then
warn("Return = nil")
end
end
The parameter of the function GetPlayerByUserId() should be receiptInfo.PlayerId instead of receiptInfo.ProductId
local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
if not game.Players:GetPlayerByUserId(receiptInfo.PlayerId) then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receiptInfo.ProductId == 123123 then -- our product id
print('works')
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end