game.Players.PlayedAdded:connect(function(player)	
	player.Chatted:connect(function(msg)
		local function saidWord(message, word)
			return string.match(string.lower(message), string.lower(word))
		end
	       	if msg == saidWord(msg, "hello") then 
			print(msg)
	        end
	end)
end)

I have this script, so when a player chats something, and if that something is 'Hello', then it will print the message in the output. What I want though is sometimes players say 'Hello, how are you', or something like that, where they say 'Hello', but they add more to the message. Is it possible to pick it up if the word is used in a sentence.

EDIT

It does not print the message unless you say 'hello'

10 comments

0

try string.find

0

String.find does not work at all.

0

You didn't answer it, cause it didn't work.....

0

Copy exatly what I wrote, paste it in to a clean script, and try it

0

Still does not work

0

Everytime I say a word it prints, even if the word isn't Hello

0

I editted my question with the exact code in the script. It does not work unless I just say hello in lowercase...

0

Your boolean expression is wrong. The function returns hello or nil and you are comparing it to the entire message. Try just putting if saidWord(msg, "hello") then