Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix this case sensitive and argument issue in my admin script?

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 it 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)

2 comments

0

where in the script do you want me to put that?

1

nvm its complicated to understand ill just make an answer

1 answer

local commands = {"kick","help","ban"}
game.Players.LocalPlayer.Chatted:Connect(function(message)
	for _, v in pairs(commands) do
		if string.find(message,v) then
			if string.find(message,v) then
				local len = string.len(v)+2 -- whitespace plus the prefix. make sure the prefix is one letter.
				local removedWords = string.gsub(message,tostring(":"..v.." "),"")
				print(tostring(":"..v.." "))
				local lowercase = string.lower(removedWords)
				print(len,removedWords,lowercase)
				for _, x in pairs(game.Players:GetPlayers()) do
					if string.find(string.lower(x.Name),lowercase) then
						print(v," command goes to ",x.Name)
					end
				end
			end
		end
	end
end)

So this is what I made, when I typed :kick great (since I am greatneil80)

It returns "kick command goes to greatneil80"

6 comments

0

Also I didn't understand what you meant in 2

0

So if I did :kick cha Exploiting bye bye, it would say the whole thing in the kick message "Exploiting bye bye" instead of just "Exploiting"

0

Please accept this if it worked, I took 15 mins to do this

0

yes

0

oh you want everything past that too?

0

like other usernames?

This discussion is preserved as it was. New answers, comments, and votes are closed.