Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED]Weird error regarding developer product?

Asked by 4 years ago
Edited 4 years ago

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!

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

Answer this question