This script is supposed to detect when a player says anything with the words "What", "He", and "Do", or "What", "It", and "Do", or "What", "You", and "Do".
However, while it does so just fine, it also detects "He", "It", and "You" in any context with or without the other words.
words = {
--["Explain Function"]
words = {
{"What","It","Do"},
{"What","He","Do"},
{"What","You","Do"},
},
func = function( p ) -- functions go HERE
print(p.Name .. " asked Faraday to explain his function")
game.ServerScriptService.FaraVoice.Value = "Currently I am programmed to respond to certain phrases, however soon I will run this house."
wait(0.3)
local text = game.ServerScriptService.FaraVoice.Value
local y = game:GetService("Chat"):Chat(Interfaces, ""..text, Enum.ChatColor.Green)
end
}
}
function onChatted(msg, recipient, speaker)
print("chatted")
local source = speaker
msg = string.lower(msg)
print(#phrases,type(phrases))
for a=1,#phrases do--search command types
local _a = phrases[a].words
for b=1,#_a do -- search words
local _b = _a[b]
if(msg:match(string.lower(_b[2])))then
print(msg,_a[2])
phrases[a].func(source)
return
end
end
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)

1 comment
Thanks for that. I basically just used your code as a template to make my own with some help from a friend, because I couldn't understand yours well enough to make it do what I wanted it to. I thought I PMed you about it, but I guess I was wrong. Anyway, thanks again! You're the reason this project is even possible.