Roblox Autocomplete

An automatic fill that is very easy and quick to use, and can be used to fill in player names or any database offered. Example:
If you need to autocomplete a box to search for a player’s name, whether in an invite, bank, or admin system. You can only do this with the necessary database, any other character without there being white spaces between them.

How to use:

  • Put the module in a path

  • Require it

  • Follow the example:

local AutoComplete = require(Path/To/Object).new()

AutoComplete.TextLabel = TextLabel -- Text label that will have the shaddow effect
AutoComplete.TextBox = TextBox -- Box that player will write
AutoComplete:DataBase(ListOfPossibleCharacters)

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
  AutoComplete:Update()
end)

Code:

local AutoComplete = {}
local Standart = {} 


type Standart = {
	TextBox : TextBox, 
	TextLabel : TextLabel, 
	Update : (Standart) -> nil,
	DataBase : <Args>(Args:{}) -> nil, 
}

AutoComplete.new = function() : Standart
	return setmetatable({}, {__index = Standart})	
end


function Standart:DataBase(Data)
	local _Data = {} 
	for _, __Data in Data do 
		if typeof(__Data) == "Instance" then
			table.insert(_Data, __Data.Name)
		else 
			table.insert(_Data, __Data)
		end
	end
	self.Data = _Data
end

function Standart:Clear()
	table.clear(self)
end

function Standart:Update()
	local Text = self.TextBox.Text
	local Match = false
	for _, Data in self.Data do 
		if Data:sub(1, #Text) == Text then
			self.TextLabel.Text = Data
			self.Matched = true
			Match = true
			break
		end
	end

	if not Match then 
		self.TextLabel.Text = ""
		self.Matched = false
	end
end


return AutoComplete

Result:
image

Any errors warn here or in the github repository please

8 Likes

Any errors or suggestions please warn me on discord or github

2 Likes