I want the admin system I am creating to run the command if a command name is found within the message (i.e. :kick) with the arguments provided.
The commands won’t run and is not throwing any errors.
Not much since this is a custom admin system. I have not looked on the DevForum for answers.
This is what it looks like in the explorer:
"Admin" code
local commands = {}
local admins = {}
local ranks = {}
local services = require(script.Modules.Services)
local commandsfolder = script.Commands
local config = require(script.Configuration)
local function CheckAdmin(player)
if admins[player.Name] then
return true
elseif not admins[player.Name] then
return false
end
end
local function CheckRank(player)
if admins[player.Name] then
return admins[player.Name]
end
end
for a,b in next,script.Commands:GetChildren() do
if b:IsA("ModuleScript") then
commands[b.Name] = require(b)
end
end
for key, value in pairs(config.Admins) do
admins[value] = true
end
for key, value in pairs(config.Ranks) do
ranks[value] = true
end
services.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg, rec)
if CheckAdmin(player) then
local command, targetPlayerName = msg:match("^/(%S+)%s+(%S+)")
if command and commands[command] then
local targetPlayer = game.Players:FindFirstChild(targetPlayerName)
if targetPlayer then
commands[command](player, targetPlayer)
else
warn("Invalid Command ran from "..player.Name..": "..command)
end
end
end
end)
end)
"Kick" code
return function(player,targetplayer)
targetplayer:Kick(player.Name.." has kicked you from the server!")
end
"Services" code
local Services = {
Players = game:GetService("Players"),
TeleportService = game:GetService("TeleportService"),
Teams = game:GetService("Teams"),
DatastoreService = game:GetService("DataStoreService"),
TestService = game:GetService("TestService"),
TextChatService = game:GetService("TextChatService"),
MarketPlaceService = game:GetService("MarketplaceService")
}
return Services
"Configuration" code
local Config = {
Prefix = ":",
AutoKickBan = true,
AutoBanned = {"USERNAMEHERE","USERNAMEHERE2","USERNAMEHERE3"},
Ranks = {
Owner = {5},
HeadAdmin = {4,{}},
Admin = {3,{}},
Mod = {2,{}},
VIP = {1,{}},
Player = {0,{}},
};
Admins = {
["Jerold09362"]= 5,
}
}
--[[ CONFIG HELP
Prefix is the first character that seperates a message from a command. For example, the ':' in :kick bob.
AutoKickBan is whether or not the game will kick/ban people who are in the AutoBanned table.
AutoBanned is a list of people that will be kicked/banned automatically.
Ranks is a list of people and their ranks. The higher the rank, the more commands they will have access to.
Admins is a list of people who will have access to admin commands.
[RANKNUMBER] = "PLAYERNAME"
]]
All help is appreciated.