Pretty much all I want is to search through the table to see if the player said any words that are inside the table then it’ll run my code.
local table = {
"No",
"Yes",
"Maybe"
}
elseif string.lower(message) == --table search to see if one of words was said
then
print("Kidnapped".. player.Name)
end
local Words = {
"No",
"Yes",
"Maybe"
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message, Speaker)
for _,v in Words do
if v:lower():match(Message:lower()) then
print("Kidnapped "..Player.Name)
break
end
end
end)
end)
If you don’t want a loop you can use this. Since the strings in Words have their first letter capitalized, we take the message the player said, lower it, then capitalize the first letter;
local Words = {
"No",
"Yes",
"Maybe"
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message, Speaker)
local Word = Message:lower()
Word = string.gsub(Word, "^%l", function(letter) return string.upper(letter) end)
if table.find(Words, Word) then
print("found it again.")
end
end)
end)