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

4 comments

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

0

^ I agree, try remote events

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

0

I agree with the first commenter, this needs a RemoteEvent to send the text to the server for the server to read.