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

Why do my variables keep coming back as nil?

Asked by
Jo1nts 134
2 years ago

I am trying to access a players GUI text through their PlayerGui(player.Playergui.MainUI). The script is able to access the path, but when it returns the GUI text it returns to nil. Even though there is text inside the GUI label.

SCRIPT IS LOCATED IN SERVERSCRIPTSERVICE

Main Code:

local orderinfo 
local buyer
local artist
local typ 
local amount
local desc

MarketplaceService.ProcessReceipt = function(receiptInfo)

    local user = getUsernameFromUserId(receiptInfo.PlayerId) --working function


    if user then

        --THESE VARIABLES RETURN NIL OR BLANK
        orderinfo = user.PlayerGui.MainUi.Frame.pages.Order
        buyer = orderinfo.contact
        artist = orderinfo.dropdown
        typ = orderinfo.dropdown1
        amount = orderinfo.subtotal
        desc = orderinfo.desc

        postToDiscord(receiptInfo.PlayerId,user,buyer.Text,artist.Text,typ.Text,amount.Text,desc.Text) -- working function

            return Enum.ProductPurchaseDecision.PurchaseGranted
        else
            return Enum.ProductPurchaseDecision.NotProcessedYet
    end
end

0
Can this be because you are trying to read text which is only seen client and not server? Try RemoteEvents or in this case :InvokeClient with RemoteFunctions to send text of all the elements in a table from client to server imKirda 4491 — 2y
0
^ I agree, try remote events boomthefist 6 — 2y
0
i think this can be because ur setting the variables first but then ur adding value later, mabe try making the variales under the "if user then" instead of at the top againroblo 0 — 2y
0
I agree with the first commenter, this needs a RemoteEvent to send the text to the server for the server to read. PaleNoobs 37 — 2y

Answer this question