-
I want to be able to sell developer products, and i got to the point that it works in play mode, but not in local test / acutal game.
-
As mentioned above, i receive the items in play mode, but not local test / acutal game. in play mode i get the error occured warn from line 34 of server script
-
I have consulted a friend of mine and we spent some time looking at it, and it just doesnt work.
--SERVER SCRIPT
local MS = game:GetService("MarketplaceService")
local RS = game:GetService("ReplicatedStorage") -- holds buyables
local Products = {
[1377321773] = function(receipt, player)
RS.Buyables["Gravity Coil"]:Clone().Parent = player:WaitForChild("Backpack")
end,
[1377348243] = function(receipt, player)
RS.Buyables.Balloon:Clone().Parent = player:WaitForChild("Backpack")
end,
[1377348296] = function(receipt, player)
RS.Buyables.GrappleHook:Clone().Parent = player:WaitForChild("Backpack")
end,
[1377348977] = function(receipt, player)
RS.Buyables.FlyingCarpet:Clone().Parent = player:WaitForChild("Backpack")
end,
}
function processReceiptFunction(receiptinfo)
local playerProductKey = receiptinfo.PlayerId..":"..receiptinfo.PurchaseId
local plr = game:GetService("Players"):GetPlayerByUserId(receiptinfo.PlayerId)
local handler
for ProductId, func in pairs(Products) do
if ProductId == receiptinfo.ProductId then
handler = func
break
end
end
--NEW CODE
local suc, result = pcall(handler, receiptinfo, plr)
if not suc or not result then
warn("error occured")
end
--END OF NEW CODE
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MS.ProcessReceipt = processReceiptFunction
-- BUY PART SCRIPT
script.Parent.Triggered:Connect(function(player)
if player then
game:GetService("MarketplaceService"):PromptProductPurchase(player, 1377348243)
end
end)