Skip to content
This repository has been archived by the owner on Nov 10, 2018. It is now read-only.

Error in PurchasePromptScript #306

Closed
TheSneak opened this issue May 16, 2014 · 5 comments
Closed

Error in PurchasePromptScript #306

TheSneak opened this issue May 16, 2014 · 5 comments
Labels

Comments

@TheSneak
Copy link

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
@Anaminus Anaminus added CoreLib and removed CoreLib labels May 16, 2014
@SNCPlay42
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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

@TheSneak
Copy link
Author

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
Copy link
Owner

Issue submitted to ROBLOX/Core-Scripts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants