Check player if they said a certain word

The title says it all. How to check player if they said a certain word?

game:GetService('Players').PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		-- if they said certain word in the sentences. Eg: hello, Hello, Hello my name is bob, Hello guys, HELLO! or hElLo
	end)
end)
1 Like

You have use string.find for doing that.

String.find helps you search for a certain pattern of words from a sentence.

1 Like

idk if that is correct or not:

local lowered = string.lower(message)
if string.find(lowered, "hello") ~= nil then

end
2 Likes

When I said HeLlO, it works!

1 Like

This is a slight modification to @nuttela_for1me 's script.

game:GetService('Players').PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		Message = string.lower(Message)
if string.Find(Message, "hello") then
-- what you want the code to do
end
	end)
end)
4 Likes