Good afternoon,
I am making an admin system, and I want to know how I can make this command not break when a reason isn't provided.
:kick me should work
:kick me Bye should also work.
local Owners = {"", ""}
local SuperAdmins = {"", ""}
local Administrators = {"", ""}
local Moderators = {"", ""}
local Banlist = {"", ""}
local BanMessage = ""
local Prefix = ":"
local KickCommand = Prefix.."kick "
local FireCommand = Prefix.."fire "
game.Players.PlayerAdded:Connect(function(p)
local AdminLevel = Instance.new("Folder", p)
AdminLevel.Name = "AdminLevel"
local AdminValue = Instance.new("IntValue", AdminLevel)
AdminValue.Name = "AdminValue"
AdminValue.Value = 0
for i,v in pairs(Banlist) do
if p.Name == v then
p:Kick(BanMessage)
end
end
for i,v in pairs(Moderators) do
if p.Name == v then
p.AdminLevel.AdminValue.Value = 1
end
end
for i,v in pairs(Administrators) do
if p.Name == v then
p.AdminLevel.AdminValue.Value = 2
end
end
for i,v in pairs(SuperAdmins) do
if p.Name == v then
p.AdminLevel.AdminValue.Value = 3
end
end
for i,v in pairs(Owners) do
if p.Name == v then
p.AdminLevel.AdminValue.Value = 4
end
end
if p.UserId == game.CreatorId then
p.AdminLevel.AdminValue.Value = 5
end
if p.AdminLevel.AdminValue.Value >= 1 then
p.Chatted:Connect(function(msg)
local arguments = string.split(msg, " ")
if arguments and arguments[2] then
if arguments[1] == KickCommand then
local name = (arguments[2] == "me" and p.Name) or arguments[2]
local reason = arguments[3] and arguments[3] or "Unspecified reason."
local full = game.Players:GetPlayers()
print(name)
local player = game.Players:FindFirstChild(name)
if player then
player:Kick("Kicked by: "..p.Name..". Reason: "..reason)
else
local clone = script.Error:Clone()
clone.Parent = p.PlayerGui
clone.Frame.TextLabel.Text = "Error: Player(s) is not in game!"
wait(2)
clone:Destroy()
end
end
end
end)
end
end)
Any suggestions or ideas?

7 comments
Hey, I wanted to answer this!
Jesus. Did you have to go so hard on the String Manipulation? Also, use UserId arrays, the admin can change their name at any time, and it can be tedious to continuously change the list
this just an example, he can change if he wants. I'd actually use user IDs if i was doing this for my self
How am I to put this into my full code?
^ I updated it to show my whole script.
to do that, you'd have to check what admin rank the player is when they join, then when they chat, you check whether the command is in the player rank's admin list
if so, then you call the function corresponding to the admin.