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

How would you make a player's name show up in a textbox?

So I'm trying to make something so when I type someones name the rest of the name would pop up

So if i type Bob in the textbox it would check if the player was in the server, if the player is then it would replace the textbox text with the full username

if i put hi but the full username was hiimbob then it would replace the text with hiimbob

heres a pic of what i mean https://cdn.discordapp.com/attachments/511168067515187211/586974531386736643/unknown.png when u type the d u can see the full username

if anyone can help then thanks

5 comments

0

picture is blocked

0

oh lemem update it

0

add me on discord ill send it there LEWIS1063#0743

0

added u there, user is world killer

2 answers

First, we should check if the person is in the server when we press the Enter button.

If so, we autocomplete.

local Text = TEXTBOX_HERE;
local newText;
Text.Changed:Connect(function(t)
	if (newText) then newText:Destroy() end; --Delete any old text
	--Copy the text properties
	newText = Instance.new('TextLabel', script.Parent.Parent);
	newText.Name = 'NewText'
	newText.Font = Text.Font;
	newText.Text = '';
	newText.Size = Text.Size;
	newText.Position = Text.Position;
	newText.Visible = Text.Visible;
	newText.TextXAlignment = Text.TextXAlignment;
	newText.BackgroundTransparency = 1;
	newText.TextYAlignment = Text.TextYAlignment;
	newText.ZIndex = -50;
	newText.TextScaled = Text.TextScaled;
	newText.TextSize = Text.TextSize;
	local C = Text.TextColor3;
	newText.TextColor3 = Color3.fromRGB(C.r-50, C.g - 50, C.b - 50);
	--Check
	for i, v in pairs(game:GetService('Players'):GetPlayers()) do
		if (v.Name:lower():match(Text.Text:lower()) and Text.Text ~= '' ) then --if the name has a match for the textbox's text
			newText.Text = v.Name; 
			newText.Parent = Text.Parent;
		end
	end
end);

This will work if you type in bob, hiim, hi, ob, and etc. This works great if you remember a part of someone's name, but not the entire thing. Capitalization does not matter.

9 comments

0

I get a red underling of the then on line 6

0

Fixed, I completely forgot about the parenthesis. Try it now, please.

0

it works but i want it to say the full name as im typing it, not when i press enter

0

finished done bye

0

doesnt work

0

doubt it. worked on mine, error is on your side lol.

0

what type of script, local or normal?

0

local

0

do i put the script inside the textbox?

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