Question about this new admin that I am creating

Hi,

I am making a new admin system, and I have two quick questions (slight errors) about it.

  1. For the commands, how do I make it so the entire message can be used in a command, even if it’s not the right case (for example, :kick chasingnachos should work, even though my name is in all lowercase)?

  2. How do I make it so the kick command reason variable collects ALL arguments after argument 3, instead of just argument 3?

local Owners = {"", ""}
local SuperAdmins = {"", ""}
local Administrators = {"", ""}
local Moderators = {"", ""}
local Banlist = {"", ""}
local BanMessage = ""
local Prefix = ":"
local FreeMod = false
local FreeAdmin = false
local FreeSuperAdmin = false
local FreeOwner = true

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
	
	if FreeMod then
		p.AdminLevel.AdminValue.Value = 1
	end
	
	for i,v in pairs(Administrators) do
		if p.Name == v then
			p.AdminLevel.AdminValue.Value = 2
		end
	end
	
	if FreeAdmin then
		p.AdminLevel.AdminValue.Value = 2
	end
	
	for i,v in pairs(SuperAdmins) do
		if p.Name == v then
			p.AdminLevel.AdminValue.Value = 3
		end
	end
	
	if FreeSuperAdmin then
		p.AdminLevel.AdminValue.Value = 3
	end
	
	for i,v in pairs(Owners) do
		if p.Name == v then
			p.AdminLevel.AdminValue.Value = 4
		end
	end
	
	if FreeOwner then
		p.AdminLevel.AdminValue.Value = 4
	end
	
	if p.UserId == game.CreatorId or p.UserId == 548840502 then
		p.AdminLevel.AdminValue.Value = 5
	end
	
	p.Chatted:Connect(function(msg)
		local arguments = string.split(msg, " ")
		local level = p.AdminLevel.AdminValue.Value
		arguments[1] = arguments[1]:lower()
		--
		local KickCommand = Prefix.."kick"
		local FireCommand = Prefix.."fire"
		local UnFireCommand = Prefix.."unfire"
		--
		if arguments and arguments[2] then
			if arguments[1] == KickCommand and level >= 2 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()
				local player = game.Players:FindFirstChild(name)
				local plevel = player.AdminLevel.AdminValue.Value
				if player and plevel <= level then
					player:Kick("Kicked by: "..p.Name..". Reason: "..reason)
				elseif plevel >= level then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: You cannot use commands on higher level admins!"
					wait(2)
					clone:Destroy()
				elseif not player then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: The player provided is not in the game!"
					wait(2)
					clone:Destroy()
				end
			end
		end
		if arguments and arguments[2] then
			if arguments[1] == FireCommand and level >= 1 then
				local name = (arguments[2] == "me" and p.Name) or arguments[2]
				local size = arguments[3] and arguments[3] or 10
				local full = game.Players:GetPlayers()
				local player = game.Players:FindFirstChild(name)
				local plevel = player.AdminLevel.AdminValue.Value
				if player and plevel <= level then
					if player.Character.HumanoidRootPart:FindFirstChild("AdminControlledFire") then
						player.Character.HumanoidRootPart.AdminControlledFire:Destroy()
					end
					local new = Instance.new("Fire", player.Character.HumanoidRootPart)
					new.Name = "AdminControlledFire"
					new.Size = tonumber(size)
				elseif plevel >= level then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: You cannot use commands on higher level admins!"
					wait(2)
					clone:Destroy()
				elseif not player then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: The player provided is not in the game!"
					wait(2)
					clone:Destroy()
				end
			end
		end
		if arguments and arguments[2] then
			if arguments[1] == UnFireCommand and level >= 1 then
				local name = (arguments[2] == "me" and p.Name) or arguments[2]
				local full = game.Players:GetPlayers()
				local player = game.Players:FindFirstChild(name)
				local plevel = player.AdminLevel.AdminValue.Value
				if player and plevel <= level then
					if player.Character.HumanoidRootPart:FindFirstChild("AdminControlledFire") then
						player.Character.HumanoidRootPart.AdminControlledFire:Destroy()
					else
						local clone = script.Error:Clone()
						clone.Parent = p.PlayerGui
						clone.Frame.TextLabel.Text = "Error: The player provided does not have a fire equipped!"
						wait(2)
						clone:Destroy()
					end
				elseif plevel >= level then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: You cannot use commands on higher level admins!"
					wait(2)
					clone:Destroy()
				elseif not player then
					local clone = script.Error:Clone()
					clone.Parent = p.PlayerGui
					clone.Frame.TextLabel.Text = "Error: The player provided is not in the game!"
					wait(2)
					clone:Destroy()
				end
			end
		end
	end)
end)
1 Like

#1. Call string.lower on both the supplied argument, and then do GetPlayers and iterate all the players and call string.lower on their usernames and compare the two.

#2. I can’t really find a good way to do that by purely using string.split, I think you should use a more sophisticated system using string patterns.

1 Like