The goal of this is to determine what product the person buys, and how many seconds it corresponds to in the table. Currently, it prints nil at this part:
print(PaymentTable[receiptInfo.ProductId])
I’ve tried to debug it with various methods, and just can’t find the problem.
local PaymentTable = {
['1167769246'] = 1,
['1167769541'] = 55,
['1167769540'] = 10,
['1167769537'] = 30,
['1167769536'] = 60,
['1167769535'] = 300,
['1167769533'] = 600,
}
local MarketplaceService = game:GetService("MarketplaceService")
function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- script below controls what happens if bought
print(player.Name .. " just bought " .. receiptInfo.ProductId)
--// do stuff
--print(player.Name .. ' just bought ' .. PaymentTable[receiptInfo.ProductId])
print(PaymentTable[receiptInfo.ProductId])
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt