Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Checking if TextBox.Text contains the string in the table. But it doesn't work?

Asked by
ziploz 7
6 years ago

I am making a script inside TextButton script that will check if the TextBox contains any of the word or string inside the table.

text = script.Parent.Parent:WaitForChild('TextBox')
label = script.Parent.Parent:WaitForChild('TextLabel')

a = {'ziploz','flyemirates27','groovydominoes52'}

script.Parent.MouseButton1Click:connect(function()
    if string.match(text.Text, a) then
    label.Text = "The word "..text.Text.." was found in the table."
else
    label.Text = "The word "..text.Text.." was not found in the table."
end
end)

What's the right way to do it?

0
Instead of "if string.match(text.Text, a) then" try "if text.Text:match(a) then" MachoPiggies 526 — 6y
0
It shows an error "String expected, got table", Is there any way to get all text in the table? ziploz 7 — 6y
0
how about string.match(text.Text, "a") USARMY500 0 — 4y

Answer this question