Fetch Player's ID through use of TextBox?

@Quoteory
image
Getting there but I see it still prints when there is only placeholder text, while it specifies actual text, is this a mistake or does the gui/script see text and placeholdertext as the same thing?

Try this?

local TextBox = script.Parent -- Identify the TextBox
TextBox.Text = ""
local remote = game:GetService("ReplicatedStorage").RemoteEvent

function SendToServer()
	
	if TextBox.Text ~= "" and TextBox.Text:upper() == TextBox.Text  then
		
		print("works")
		
		remote:FireServer(tostring(TextBox.Text))
		
	end
	
end
-- Add a event that can be run to send the info to the server
TextBox:GetPropertyChangedSignal("Text"):Connect(SendToServer)

I hooked the Property Changed Signal to make sure it only receives input from the Text as an Example.

2 Likes

Wow. Like, four people asked the same question at the start.

Heya. Sounds like you’ve got an XY Problem on your hands, or something similar to it. Your issue isn’t fetching the Player’s UserId from a TextBox, it’s the application of your code here.

Keep in mind that more than one value is returned from GetUserThumbnailAsync. You should attempt to make use of these arguments, because that may be part of your problem (you can use these to debug).

As a side note, for good practice, you should wrap this in a pcall. GetUserThumbnailAsync is a web call internally, therefore if it fails it can also terminate your thread. Here’s a little test you can try.

local Players = game:GetService("Players")

local success, content, ready = pcall(Players.GetUserThumbnailAsync, Players, UserId, ThumbnailType, ThumbnailSize)
if success then
    if ready then
        ImageLabel.Image = content
    else
        -- Handle image not ready
    end
else
    -- Handle call failure
end

I do believe that the string of content remains empty if the image is not ready to be used, though I could be wrong. I haven’t really touched this function.

Do lots of debugging. Try throwing print statements around in your code to see where exactly your implementation isn’t working out and to see what gets returned from some calls.

I can’t really grasp the issue because there are obscure respond-and-grab messages here. What’s primarily your issue? Is everything working except the display of images, or is your code having errors as well? Checking the console would also help out.

1 Like