How to check if a textbox contains a specific string of words?

How would I make it so that when the player enters text in a TextBox and presses a TextButton a script checks to see if the textbox contains a certain word? Any help is appreciated. Example:

Text = “They did not like that pizza with cheese.”
if Text contains “They did not like” then
do stuff here
end

1 Like

Could try using string.find?

if string.find(Text, "They did not like)"  then

Could also use string.match

if string.match(Text, "They did not like") then
1 Like

Ah, I see. I didn’t know this existed. Thanks for the solution and another piece of knowledge.

All good. The string library has all sorts of useful things!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.