To cut to the chase, in my game you have to buy a developer product if you want to switch teams mid-game. Once I test my game in studio, I am prompted with this error:
"20:24:31.994 - ServerScriptService.gaurdSwitchPurchase:4: attempt to index local 'receiptInfo' (a nil value) 20:24:31.995 - Stack Begin 20:24:31.995 - Script 'ServerScriptService.gaurdSwitchPurchase', Line 4 - local processReceipt 20:24:31.996 - Script 'ServerScriptService.gaurdSwitchPurchase', Line 12 20:24:31.996 - Stack End"
I dont know why I would be getting this error because my code looks pretty error-less but here is the code in question:
local MarketplaceService = game:GetService("MarketplaceService")
local function processReceipt(receiptInfo)
local Player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not Player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(receiptInfo.PlayerId .. " just bought ".. receiptInfo.ProductId)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt()
Also, CharacterAutoLoads is set to false and the gui where you're supposed to be prompted with this purchase is inside ReplicatedFirst if that has to do with anything. Thank you!

4 comments
Remove the () on line 12, as this calls the function
didnt work :/
if functions were defined so that you must use a ":" instead of a ".", i dont think you can change it
can you elaborate a little bit. I don't seem to understand.