User IDs & ScreenGui Scripting

I’m trying to figure out how I can make the following steps:

  1. A Player types the full Username of a Player in a TextBox.
  2. The same Player clicks a TextButton after doing the first step.
  3. A TextLabel outputs the UserId of that Player that was typed in the TextBox.

I’m not asking anyone for a full script but just a basic example that would help me achieve what I’m happy with.

Thank you everyone that considers helping!

You need to use .FocusLost event on textbox and get the .Text property inside of the textbox and use the players service function :GetUserIdFromNameAsync with the .Text property to get it and use .UserId in the result of the players service async

Can I use anything that is “RoProxy” related?

Depends, if its something like “online” you can use it because you want to other players see his userIds. But you will need to add more things to what i said in my first post

Here is a basic version:

Button.MouseButton1Click:Connect(function() -- The button clicked

    local Input = TextBox.Text  -- Text inputted into textbox

    if #Input == 0 then -- Checks if the textbox is empty
        -- No username inputted (display error or do nothing)
    else

        local UserId = pcall(function()
            return game.Players:GetUserIdFromNameAsync(Input) -- Get UserId
        end)

        if not UserId then -- If error then ...
            UserId = 0 -- Set to a default value or display error
        end

        TextLabel.Text = Result -- Display result on text label
    end

end)

I haven’t tested the code but I think it should work
Hope this helps :slight_smile:

1 Like