So I have a script and when the "Admin" speaks a certain Phrase it executes a function but when I speak (I'm an Admin.) It executes the function to ANYTHING that I say and not the desired phrase/command. Here is the script. Please help! Much apreciated! :)
Admins = {"doctorbenny2011"} function onChatted(msg) if string.find(string.lower(msg), string.lower("Vortex")) and string.find(string.lower(msg), string.lower("Open!")) then on() if string.find(string.lower(msg), string.lower("Vortex")) and string.find(string.lower(msg), string.lower("Close!")) then off() end end end game.Players.PlayerAdded:connect(function (guy) for i,v in pairs(Admins) do if string.lower(guy.Name) == string.lower(v) then guy.Chatted:connect(onChatted) guy.Chatted:connect(onChat) end end end) off()
It will be alot easier to make a command a new way using a function called onChatted(message, player)
Admins = {"doctorbenny2011"} function onChatted(message, player) if string.lower(message:sub(1,7)) == "Vortex " then if Admins[player.Name] then if message:sub(8) == "Open!" or "open!" then on() elseif message:sub(8) == "Close!" or "close!" then off() end end end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end)
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end) Calls the function every time someone talks when they are added to the server and sends the function the arguments message, player. if message.lower(:sub(1,7)) == "Vortex " then this checks the first 7 letters of the word for Vortex with a space afterwards. if Admins[player.Name] then This finds the table Admins and searches for the players name from the game.Players.PlayerAdded event and checks if it matches any of the names in the list. if message:sub(8) == "Open!" or "open!" then This then checks the letters after 8 to see if they match Open! or open! and calls the function on() elseif message:sub(8) == "Close!" or "close!" then This does the same as Open! but calls the function off()