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!