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

Admin Command Not Working?

I am making admin commands open source but there are no errors but it's not working and I dont know why. I think it has something to do with commandcheck function? But i'm not sure

--[[
Project: AdminC Framework[Open Source]
Lead Developer: devSeldom 
Contributers: PreyStar, LegitimatlyMe
Progresion: 80% needs more commands adding types of Groups and acronymns

Description:
AdminC Framework is an open source administrative framework which impowers users to create administrator rights
efficiently and effortlessly. 


Distributed by devSeldom and affilitates
--]]

--Settings
local Settings = 
{
Admins = {"devSeldom","hungryjaffer","PreyStar", "LegitimatlyMe"}, -- first level
Moderators = {"Name"}, -- 2nd level
AdminsOnline = {},
ModsOnline = {},
FireKey = ";",
BanList = {},
Log = {},
}

local Commands =
{
	
	-- 3 variables 1. Name 2. Groups Expected 3.function
	{"kill", ListExpected = 1,
		function(list) 
			group1 = list[1]
		for i,player in pairs(group) do 
		if v.Character then 
			v.Character.Humanoid.Health = 0 
		end
	end
end},

}



--[[ 

    WARNING DO NOT EDIT ANYTHING UNDER THIS LINE AS IT CAN BREAK THE ADMIN SCRIPT
	ONLY EDIT IF YOU KNOW WHAT YOU ARE DOING
--]]



--Compares string to a table
local checkstringtable = function(table,check)
    for i,v in pairs(table) do
        if string.lower(v) == check:lower() then
            return true
        end
    end
end

--Fired by chat
function commandcheck(msg,sender)
	--Logs The Command
	print(sender.Name.." Commanded("..tostring(game.Workspace.DistributedGameTime/60).." minutes ago) "..msg)
	table.Insert(Settings.Log, sender.Name.." Commanded("..tostring(game.Workspace.DistributedGameTime/60).." minutes ago) "..msg)
		
	--Variables
    local words = {}
    local lists = 0
    local liststabs = {}
    
    --Seperates words by space
    for word in text:gmatch("[^" .." ".. "]+") do 
        table.insert(words, word)
    end
    
    --Number of groups of people
    lists = #words-1
    
    --Makes words lower
    for i,v in pairs(words) do
        v = v:lower()
    end
   
    -- Seperates groups into a table for the groups
    for i=1,lists do
    	namelist = {}
    for name in text:gmatch("[^" ..",".. "]+") do -- seperates names by a ,
        table.insert(namelist, word)
    end
    table.insert(liststabs,namelist)
end
	
	-- Replaces the list made with players and removes ones that dont match
	for i = 1, lists do
		for i,name in pairs(liststabs[i]) do
			local namefound = false
			for i,player in pairs(game.Players:GetChildren()) do
				if name:lower() == player.Name:sub(1,name:len()) then
					namefound = true
					name = player
				end
			end
			if namefound == false then
				table.remove(liststabs[i],name)
			end
	end
end

--Fires
for i,v in pairs(Commands) do 
	if v[1]:lower() == words[1]:sub(2,words[1]:len()):lower() and lists >= v[2] then
		v[3](liststabs)
	end
end

end

game.Players.PlayerAdded:connect(function(player)
	
	--Checks settings if they are mods
    admincheck = checkstringtable(Settings.Admins,player.Name)
    modcheck = checkstringtable(Settings.Moderators,player.Name)
    
    --Adds player to mod table
    if modcheck == true then
        table.insert(Settings.ModsOnline,player.Name)
    end
    
    --Adds player to Admin table
    if admincheck == true then 
        table.insert(Settings.AdminsOnline, 1, player.Name)
    end
    
    --Removes player from mod table if the player is in admin table
    if modcheck == true and admincheck == true then 
        table.remove(Settings.ModsOnline,player.Name) 
        table.insert(Settings.Admins,player.Name)
    end
   
   --Fires if FireKey is present 
    player.Chatted:connect(msg, player)
    if admincheck == true or modcheck == true and msg:sub(1,1) == Settings.FireKey then
    	commandcheck(msg,player)
	end
	
end)

game.Players.PlayerRemoved:connect(function(player)
	
	--Checks if player leaving is in any online tables
	local adminonline = checkstringtable(Settings.AdminsOnline,player.Name)
	local modonline = checkstringtable(Settings.ModsOnline,player.Name)
	
	--Removes from AdminsOnline table if they're in it
	if adminonline == true then
		table.remove(Settings.AdminsOnline,player.Name)
		print("Admin")
	end
	
	--Removes from ModsOnline table if they're in it
	if modonline == true then
		table.remove(Settings.ModsOnline,player.Name)
		print("Admin")
	end

end)

1 comment

0

Your problem is lines 158 and 164 (as well as lines 106 and 138); You can't give the 'table.remove' function a String/Class/Symbol, you have to give it a Number (The Position within the Table).

1 answer

✓ Accepted answer

PlayerRemoved is not a valid member of Players, I think you mean 'PlayerRemoving'.

--[[
Project: AdminC Framework[Open Source]
Lead Developer: devSeldom 
Contributers: PreyStar, LegitimatlyMe
Progresion: 80% needs more commands adding types of Groups and acronymns

Description:
AdminC Framework is an open source administrative framework which impowers users to create administrator rights
efficiently and effortlessly. 


Distributed by devSeldom and affilitates
--]]

--Settings
local Settings = 
{
Admins = {"devSeldom","hungryjaffer","PreyStar", "LegitimatlyMe"}, -- first level
Moderators = {"Name"}, -- 2nd level
AdminsOnline = {},
ModsOnline = {},
FireKey = ";",
BanList = {},
Log = {},
}

local Commands =
{

    -- 3 variables 1. Name 2. Groups Expected 3.function
    {"kill", ListExpected = 1,
        function(list) 
            group1 = list[1]
        for i,player in pairs(group) do 
        if v.Character then 
            v.Character.Humanoid.Health = 0 
        end
    end
end},

}



--[[ 

    WARNING DO NOT EDIT ANYTHING UNDER THIS LINE AS IT CAN BREAK THE ADMIN SCRIPT
    ONLY EDIT IF YOU KNOW WHAT YOU ARE DOING
--]]



--Compares string to a table
local checkstringtable = function(table,check)
    for i,v in pairs(table) do
        if string.lower(v) == check:lower() then
            return true
        end
    end
end

--Fired by chat
function commandcheck(msg,sender)
    --Logs The Command
    print(sender.Name.." Commanded("..tostring(game.Workspace.DistributedGameTime/60).." minutes ago) "..msg)
    table.Insert(Settings.Log, sender.Name.." Commanded("..tostring(game.Workspace.DistributedGameTime/60).." minutes ago) "..msg)

    --Variables
    local words = {}
    local lists = 0
    local liststabs = {}

    --Seperates words by space
    for word in text:gmatch("[^" .." ".. "]+") do 
        table.insert(words, word)
    end

    --Number of groups of people
    lists = #words-1

    --Makes words lower
    for i,v in pairs(words) do
        v = v:lower()
    end

    -- Seperates groups into a table for the groups
    for i=1,lists do
        namelist = {}
    for name in text:gmatch("[^" ..",".. "]+") do -- seperates names by a ,
        table.insert(namelist, word)
    end
    table.insert(liststabs,namelist)
end

    -- Replaces the list made with players and removes ones that dont match
    for i = 1, lists do
        for i,name in pairs(liststabs[i]) do
            local namefound = false
            for i,player in pairs(game.Players:GetChildren()) do
                if name:lower() == player.Name:sub(1,name:len()) then
                    namefound = true
                    name = player
                end
            end
            if namefound == false then
                table.remove(liststabs[i],name)
            end
    end
end

--Fires
for i,v in pairs(Commands) do 
    if v[1]:lower() == words[1]:sub(2,words[1]:len()):lower() and lists >= v[2] then
        v[3](liststabs)
    end
end

end

game.Players.PlayerAdded:connect(function(player)

    --Checks settings if they are mods
    admincheck = checkstringtable(Settings.Admins,player.Name)
    modcheck = checkstringtable(Settings.Moderators,player.Name)

    --Adds player to mod table
    if modcheck == true then
        table.insert(Settings.ModsOnline,player.Name)
    end

    --Adds player to Admin table
    if admincheck == true then 
        table.insert(Settings.AdminsOnline, 1, player.Name)
    end

    --Removes player from mod table if the player is in admin table
    if modcheck == true and admincheck == true then 
        table.remove(Settings.ModsOnline,player.Name) 
        table.insert(Settings.Admins,player.Name)
    end

   --Fires if FireKey is present 
    player.Chatted:connect(msg, player)
    if admincheck == true or modcheck == true and msg:sub(1,1) == Settings.FireKey then
        commandcheck(msg,player)
    end

end)

game.Players.PlayerRemoving:connect(function(player)

    --Checks if player leaving is in any online tables
    local adminonline = checkstringtable(Settings.AdminsOnline,player.Name)
    local modonline = checkstringtable(Settings.ModsOnline,player.Name)

    --Removes from AdminsOnline table if they're in it
    if adminonline == true then
        table.remove(Settings.AdminsOnline,player.Name)
        print("Admin")
    end

    --Removes from ModsOnline table if they're in it
    if modonline == true then
        table.remove(Settings.ModsOnline,player.Name)
        print("Admin")
    end

end)

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