Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Does anyone know how i can get roblox username and ID in a text box using a search textbox?

Hello, i've got a small problem, when it comes to finding the username and ID in a search box. Below is my current code, for my "search" box. At the moment, i need to search for a username, in order to get the image below. https://roblox-network.com/uploads/images/png/mas.png

Is there a easy way to make the search box, allow entery of eather username or user ID, And then output the user image, username in the Textbox and User ID in the other textbox?

Or do i have to use an web API to get it?

function o()
script.Parent.Parent.Parent.Parent.Parent["UI-CENTER"]["Page Content"]["UserSearch"]["Frame"].Thumbnail.Image = "https://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username=".. script.Parent.Parent.NameInput.Text
end
script.Parent.MouseButton1Down:connect(o)

3 answers

#What you can do Check if the NameInput value is not nil then we know it's a userId. If it is nil, there are letter characters. So we can assume they're meaning a username.


#tonumber Tonumber changes any value into a number. If you add a base then it counts by that base.

print(tonumber("100")) --100
print(tonumber(00001111),2) --15
print(tonumber("Hi")) --nil

if there are letters or other characters then it'll become nil.

local input = "121231312"

if tonumber(input) then
	print("Number")
else
	print("NAN") --Not a number
end

#Final Product There is another link called https://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&userid that will give you the character's profile picture through a userid.

local image = "https://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&"
local input = "script.Parent.Parent.NameInput.Text"

function o()
	if tonumber(input) then
		script.Parent.Parent.Parent.Parent.Parent["UI-CENTER"]["Page Content"]["UserSearch"]["Frame"].Thumbnail.Image = image.."userid="..input
	else
		 script.Parent.Parent.Parent.Parent.Parent["UI-CENTER"]["Page Content"]["UserSearch"]["Frame"].Thumbnail.Image = image.."username="..input
	end
end
script.Parent.MouseButton1Down:connect(o)


Hope it helps!

2 comments

0

There is multiple different profile picture styles you can use, see here: http://devforum.roblox.com/t/new-image-endpoints-that-can-be-used-in-game/28182

0

@LittleBigDeveloper, okay that's neat! I didn't make the code so I can't change it without their permission.

Note: This is an add-on to LordDragonZord's answer.

There are two useful functions inside game.Players:

game.Players:GetUserIdFromNameAsync(player_name)
game.Players:GetNameFromUserIdAsync(player_id)

These return either a number, string or nil, depending on the first parameter and the what function you are using.

This allows you to input a username, not ID, into the box, since most people wouldn't know how to get someone's ID.


Hope I helped!

~TDP

I've figured a bit more, but not 100%

I liked the options over, but it's not the exact part i was after. Also LordDragonZord's version doesn't show the image at all.

Here is a script, that i can convert the search into username, from ID But not sure how to implement it into my current search function, below the image, you will see a second image, on my current text search, if someone could help me make it, so you can eather search for name or userID it would be awesome. https://gyazo.com/be3b6292ed7675077a6f6dc37bf0cb1f.png

https://i.gyazo.com/8e7165b7bd80dacc0467778efc5ff6c6.png

This discussion is preserved as it was. New answers, comments, and votes are closed.