I am trying to use this but it won't work.
local Admins = {} table.insert(Admins, Player.Name)
I am making admin commands so when i do !admin plr they can now say the commands, which doesn't work for me..
I recommend you do something like the following:
local admins = {["EnchantedGamerOne"] = true} -- players who are admins local prefix = "!" -- prefix, for use in getCommand() local cmds = {} -- table of commands cmds.admin = function(plr) admins[plr.Name] = plr end) function getCommand(msg) local pref = string.find(msg,prefix) if pref and pref == 1 then local nmsg = string.gsub(msg,prefix,"") -- removes it from the msg local cmd = string.match(nmsg,"(%w+) ") or string.match(msg,"(%w+)") cmd = string.lower(cmd) if cmd and cmds[cmd] then local args = {} while string.match(nsmg," ") do -- stuff for putting args in here, as well as converting them to numbers, players, etc end return cmd,args end end return nil end game.Players.PlayerAdded:connect(function(p) -- when a player is added p.Chatted:connect(function(msg,rec) -- when they chat if isAdmin(p) == true then -- a function that checks to see if a player is an admin local command,args = getCommand(msg) -- a function that converts a message to a command, and returns a table full of the arguments following the command in the message if command then -- if the message was a command cmds[command](args) -- fires the function end end end) end)
This allows things to work easily when creating new commands. You will only need to put it in the cmds
table, and the code associated with it.
The getCommand
function returns:
Hope I helped!
~TDP