local prefix = "/"
local ids = {
--add player ids here for admins
}
local commands = {
hello = function(args)
print("hello"..args[1])
end,
command2 = function(args)
-- command 2 code
print("this is command 2")
end
}
game:GetService("Players").PlayerAdded:Connect(function(player)
if not table.find(ids,player.UserId) then return end
player.Chatted:Connect(function(msg)
-- parse message, call function
-- ex
local args = table.split(msg, " ")
if string.sub(string.lower(args[1]),1,#prefix) ~= prefix then return end -- i might be wrong with the string.sub part
local command = string.lower(string.sub(string.lower(args[1]),2,#args[1]))
table.remove(args,1)
if commands[command] then
commands[command](args)
end
end)
end)
and yes as you have said it is a intermidate level of scripting if you really want to then you can
local ids = {
--add player ids here for admins
}
local function command(agrs)
print("this is a command")
-- you would add command code here
end
game:GetService("Players").PlayerAdded:Connect(function(player)
if not table.find(ids,player.UserId) then return end
player.Chatted:Connect(function(msg)
-- now just call function
-- ex
local args = table.split(msg, " ")
if args[1] == "/command" then
command(table.remove(args,1))
end
end)
end)