Answered by
8 years ago Edited 8 years ago
This is a script that looks for keywords in phrases. If your phrase has ALL of the keywords in it,
for exampleJarvis
+ Armour
or even Jarvis
+ heal
,
it will run the function for the corresponding phrases. The functions for each phrase are inside the table phrases
This should be pretty straightforward but pls let me know if you have any questions - my code can be confusing
05 | words = { "Jarvis" , "Armour" } , |
07 | print (p.Name .. " activated armor function" ) |
11 | words = { "Jarvis" , "Heal" } , |
14 | print (p.Name .. " activated health function" ) |
21 | function onChatted(msg, recipient, speaker) |
24 | local source = speaker |
25 | msg = string.lower(msg) |
29 | for i,v in pairs (phrases) do |
30 | if match~ = nil then break end |
31 | print ( "no match, scanning" ) |
34 | for u,c in pairs (v.words) do |
35 | if not msg:match(string.lower(c)) then |
39 | if allFound and match = = nil then |
41 | print ( "match = " .. tostring (v)) |
46 | print ( "match found, running function" ) |
53 | function onPlayerEntered(newPlayer) |
54 | newPlayer.Chatted:connect( function (msg, recipient) onChatted(msg, recipient, newPlayer) end ) |
57 | game.Players.ChildAdded:connect(onPlayerEntered) |