I'm doing a basic script executor game and I don't want players abusing with "while true do" or "kick()". So i don't know how I can do this, but is there any feature that can detect words in the textlabel and remove them or warn the player? I don't know how I can structure this script nor i know anything to do such.
✓ ANSWER ACCEPTED
How can a textlabel find specific words and delete them?
1 answer
✓ Accepted answer
Heres basically everything about strings, I suggest reading it!
To detect words inside a string you can use:
string.find(TextLabel.Text, "kick()")
This will return the position of the second string inside the first if the first string contains it. You can use it in an if statement like this:
if string.find(TextLabel.Text, "kick()") then
...
end
To erase a word, you can use:
string.gsub(TextLabel.Text, "kick()", "")
This will replace every "second string" inside the first string with "third-string", so if you leave the third empty it will erase it. It will also return how many times it replace the word.
Hope it helps
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Thanks!
Quick question. How can I find words that are both capitalized and not capitalized? Because i need to put both "kick" and "Kick"
You can use string.lower(TextLabel.Text) to make it all lowercase, and then you can compare that with an all lowercase string. Its written down in the link i posted