Im making an admin gui, and i would like it to find all the strings that match the first string and put them in a table, which eventually i can use to make suggestions appear below where the client is typing.
What i would like if for example, I type "t" it should match up with "to" and "tp" but it doesnt, only when i type "to" will it match with "to" is it possible to fix?
local tb = script.Parent.tb
local TC = tb.Toggle_Clear
local plr = game.Players.LocalPlayer
local cmds = {
"kill";
"to";
"bring";
"tp";
"kick";
"ban";
"unban";
}
local clearon = true
TC.Activated:Connect(function()
if clearon == true then
clearon = false
tb.ClearTextOnFocus = false
TC.Text = "Clear Text On Click: OFF"
else
clearon = true
tb.ClearTextOnFocus = true
TC.Text = "Clear Text On Click: ON"
end
end)
local lastfoundnum = 0
tb.FocusLost:Connect(function()
local s1 = tb.Text
local matches = {}
local arg1 = nil
local arg2 = nil
local arg3 = nil
local arg4 = nil
local arg5 = nil
local arg6 = nil
lastfoundnum = string.find(s1, " ")
arg1 = string.sub(s1,1,lastfoundnum)
print(arg1)
for i,v in pairs(cmds)do
if string.match(string.lower(arg1),v,0) then
table.insert(matches,v)
else
print("no match")
end
end
for i,v in pairs(matches)do
print(v)
end
end)

2 comments
Also, I didn't know how to use string.match at the time so I just used loops and string.sub
so then why did you answer the question if you have no idea what you're doing