Anaminus / roblox-bug-tracker

Formerly an unofficial bug tracker for Roblox.
31 stars 24 forks source link

Error in PurchasePromptScript #306

Closed TheSneak closed 10 years ago

TheSneak commented 10 years ago

I am seeing this error in Google Analytics using the new GA module:

CoreGui.RobloxGui.CoreScripts/PurchasePromptScript:665: attempt to index upvalue 'currentProductInfo' (a nil value) | CoreGui.RobloxGui.CoreScripts/PurchasePromptScript, line 665 - global canPurchaseItem CoreGui.RobloxGui.CoreScripts/PurchasePromptScript, line 180
SNCPlay42 commented 10 years ago

Tried looking through the CoreScript myself and there's all kinds of oddities.

First is the code surrounding line 665:

    -- now we start talking money, making sure we are going to be able to purchase this
--wait, how did the code get past here if currentProductInfo is nil?
--Some other thread set currentProductInfo while getPlayerBalance() yielded?
    if not setCurrencyAmountAndType(tonumber(currentProductInfo["PriceInRobux"]), tonumber(currentProductInfo["PriceInTickets"])) then
        descText = "We could retrieve the price of the item correctly. Please try again later." 
        return true, nil, nil, true, descText
    end 

    local playerBalance = getPlayerBalance()
    if not playerBalance then
        descText = "Could not retrieve your balance. Please try again later."
        return true, nil, nil, true, descText
    end

-- Line 665 below:
    if tonumber(currentProductInfo["MinimumMembershipLevel"]) > membershipTypeToNumber(game.Players.LocalPlayer.MembershipType) then                
        notRightBc = true       
    end

Going up the call stack:

function checkIfCanPurchase()
    if checkingPlayerFunds then
        local canPurchase, insufficientFunds, notRightBC = canPurchaseItem() -- check again to see if we can buy item
--what are these boolean operations even doing? they sure don't *look* right to me
        if not canPurchase or (insufficientFunds or notRightBC) then -- wait a bit and try a few more times
            local retries = 1000
            while retries > 0 and (insufficientFunds or notRightBC) and checkingPlayerFunds and canPurchase do 
                wait(1/10)
-- a thousand retries ten times a second?! O_e
                canPurchase, insufficientFunds, notRightBC = canPurchaseItem()
                retries = retries - 1
            end
        end
        if canPurchase and not insufficientFunds then
            -- we can buy item! set our buttons up and we will exit this loop
            setButtonsVisible(purchaseDialog.BodyFrame.BuyButton,purchaseDialog.BodyFrame.CancelButton, purchaseDialog.BodyFrame.AfterBalanceText)
        end
    end
end

And the only reference to checkIfCanPurchase:

Game:GetService("GuiService").BrowserWindowClosed:connect(checkIfCanPurchase)

What is the "browser window" in this context? This doesn't seem to be connected to the usual PromptPurchase that place developers use...

matthewdean commented 10 years ago

What is the "browser window" in this context?

If you try to buy something in-game and don't have enough money, ROBLOX opens up the embedded browser to let you buy robux.

matthewdean commented 10 years ago

In the future I think these bugs should be filed here: ROBLOX/Core-Scripts

TheSneak commented 10 years ago

More info: The following error often occurs in conjunction with the initially reported error:

Argument 1 missing or nil | CoreGui.RobloxGui.CoreScripts/PurchasePromptScript, line 603 - global canPurchaseItem CoreGui.RobloxGui.CoreScripts/PurchasePromptScript, line 180
Anaminus commented 10 years ago

Issue submitted to ROBLOX/Core-Scripts.