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

Is this possible by using the chatted event?

Asked by 10 years ago

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

Log in to vote
2
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

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
0
Thank you! dpark19285 375 — 10y
Ad

Answer this question