How to make AutoComplete in a TextBox?

Hey Everyone, My Name Is Nehoray

I Started Working On A Admin Panel
But I Don’t Know How To Make AutoComplete For The Player Name In The TextBox
Thanks Everyone!

What does it have to do with the question asked in the topic?

Make a function that loops through players and checks if the name matches

function getPlrs(input) 
   local plrs = game.Players:GetPlayers()
   local results = {}
   
   for i,v in pairs (plrs) do -- loop through the players
	if v.Name:sub(1,#input):lower() == input:lower() -- we will check if the player name, all lowercased, and only the same length as input matches the input lowercased
		table.insert(results,v.Name) -- add the player name to the results
	end
   end
   
   if #results == 1 then -- if there's more then 1 player then don't return anything ( you can remove this if and just return results
	return results[1] -- just the player name, if its only 1 element no need to return a table
   else
	return {}
   end
end

textBox:GetPropertyChangedSignal("Text"):Connect(function() -- textBox is the TextBox
	local availablePlayers = getPlrs(textBox.Text)
end)
9 Likes

in which text box is the label?

What do you mean? There is no “label”, just a textbox.