Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is this possible by using the chatted event?

Hey guys! I was wondering* if it is possible *to use the Chatted Event to make it so that whenever a player chats anything with a specific word in it, a GUI would pop up. For example, let's say that the specific word is "hi". This means that if a player chats anything that has "hi" in it, such as - hi how are you doing, or hey dude, hi - a GUI would pop up. If there is a way to do this, I would highly appreciate it if someone could teach me.

Thanks in advance.

1 answer

✓ Accepted answer

Yes, gmatch, check out the first example. The "%S+ represents a string pattern or something the script searches for in a string. If you go down the page some, you can the list of patterns and what they look for. That or you can just search for the word.


local keyword = "Hi"
local chatted = "What is your name? My name is Azarth, hi Azarth! Hi creepy lady."

local keywords = 0
for i in string.gmatch(chatted:lower(), keyword:lower()) do 
	keywords = keywords + 1
end

print("There were "..keywords.. keyword.. " 's") -->There were 2 keywords.

You could also use string.find, if you don't need to find multiples.

local keyword = "Hi"
local chatted = "What is your name? My name is Azarth, hi Azarth! Hi creepy lady."

if string.find(chatted:lower(), keyword:lower()) then 
	print("found a "..keyword)
end

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.