If a table is returned, the values of the table will show up as autocomplete suggestions for the user.
Example
Shows a list of players to choose from.
local frame =vgui.Create( "DFrame" )
frame:SetSize( 300, 300 )
frame:SetTitle( "Autocompletion Example" )
frame:Center()
frame:MakePopup()
local label =vgui.Create( "DLabel", frame )
label:SetText( "Type a player..." )
label:Dock( TOP )
local textentry =vgui.Create( "DTextEntry", frame )
textentry:Dock( TOP )
functiontextentry:GetAutoComplete( text )
local suggestions ={}for _, ply inipairs( player.GetAll() ) do-- For every player,ifstring.StartWith( ply:Nick(), text ) then-- if the player's name starts with it...table.insert( suggestions, ply:Nick() ) -- ... insert it into the list.endendreturn suggestions
end