---BackGround---
So I am making a custom admin for somebody and I'm making my own to start out, but how come I can't remove or add Admins?
Information Activation Script: In ServerScriptService, name "Server", lines of code 1, and type of script normal. Main Script: In Activation Script, name adminCommands, lines of 121, and type of script Module script.
Scripts
Activation Script:
require(script.adminCommands)
Main Script:
local m={} local cmds = game.StartGui.ScreenGui.Frame --Main Event game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg,r) if r then return end end) end) --Services local dstore=game:GetService("DataStoreService") --SetUp Variables m.database=dstore:GetDataStore("adminCommands") m.adminList={ --list of userids used for first time admin use 150334552; -- My Id 21010010; -- Trusted Player's Id -1; -- For testing } m.commandStart="!" --What users will use to start the admin --Do database check local aList --Real admin list pcall(function() aList=m.database:GetAsync("adminList") end) if not aList then m.database:SetAsync("adminList",m.adminList) aList=m.adminList end --Setup parse function function m.parse(msg,player) local playerIsAdmin for a,b in pairs(aList) do playerIsAdmin=b==player.UserId if playerIsAdmin then break end end if playerIsAdmin then if msg:sub(1,1)==m.commandStart then if #msg==1 then warn("Just command signature, consider inputting a command") else local line=msg:sub(2,#msg) local command,arguments=nil,{} for a in line:gmatch("[%w%p]+") do if command==nil then command=a else table.insert(arguments,a) end end if m.commands[command] then --Command exists m.commands[command](arguments,player) else --Command does not exists warn("No Command titles".. command.." exist!") end end end end end --SetUp commands m.commands={ addAdmin=function(arg,caller) for a,b in pairs(arg) do if tonumber(b) then print("Add admin "..b) table.insert(aList.tonumber(b)) m.database:SetAsync("adminList",m.adminList) else local userid=game.Players:GetUserIdFromNameAsync(b) if userid then print("Add admin "..(b)) table.insert(aList,userid) m.database:SetAsync("adminList",m.adminList) else m.warn("addAdmin","Player name \""..b.."\" is not a valid player") end end end end; removeAdmin=function(arg,caller) for a,b in pairs(arg) do if tonumber(b) then print("Removed admin"..b) for d,c in pairs(aList) do if c==tonumber(b) then table.remove(aList,d) break end end m.database:SetAsync("adminList",aList) else local userid=game.Players:GetUserIdFromNameAsync(b) if userid then print("Removed admin"..b) for d,c in pairs(aList) do if c==userid then table.remove(aList,d) break end end m.database:SetAsync("adminList",aList) else m.warn("removeAdmin","Player name \""..b.."\" is not a valid player") end end end end; print=function(arg,caller) for a,b in pairs(arg) do print(b) end end; } --Set custom warn function function m.warn(cmd,issue) warn("In command"..m.commandStart..cmd.." issue occured, receipt: "..issue) end --Finish return m
Note: Anybody can use the fixed code!