Recently Been Trying to Setup Admin Commands on my Game. I have supposedly no Errors in my script, and my Studio has Access to API Services. i Did setup a few Breakpoints and the script seemed to me ending at "local dStore = game:GetSevice("DataStoreService")" Which is Line 12.. The module Script is Called "AdminCmds" the Parent is a Script under ServerScriptServises Called "Server" (Just In Case anyone Wanted)
local m = {}
local dStore = game:GetSevice("DataStoreService")
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg,r)
if r then return end
m.parse(msg, player)
end)
end)
local dStore = game:GetSevice("DataStoreService")
-- ( Variable Setup ) --
m.database = dStore:GetDataStore("AdminCmds")
m.adminlist = {
-- ( List of UserIds ) --
58752337;
-1;
}
-- ( Commands Prefix ) --
m.commandStart = "!" -- ( Commands Prefix ) --
---- | | ----
---- V Database Check V ----
-- ( Admin List ) --
local AList
pcall(function()
AList = m.database:GetAsync("adminList")
end)
if not AList then
m.database:SetAsync("adminList",m.adminList)
AList = m.adminlist
end
-- ( Parse Function Setup ) --
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
m.commands[command](arguments,player)
else
warn("No command titled "..command.." exists!")
end
end
end
end
end
---- | | ----
---- V Commands V ----
-- ( Add Admin ) --
m.commands = {
addAdmin = function(arg,caller)
for a,b in pairs(arg) do
if tonumber(b) then
print("Added admin " ..b)
table.insert(AList,tonumber(b))
m.database:SetAsync("adminList",AList)
else
local userid = game.Players:GetUserIdFromNameAsync(b)
if userid then
print("Added admin " ..b)
table.insert(AList,userid)
m.database:SetAsync("adminList",AList)
else
m.warn("addAdmin","Player name \""..b.. "\" is not a valid player")
end
end
end
end;
-- ( Remove Admin ) --
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;
}
-- ( Custom Warn Function ) --
function m.warn(cmd)
warn("In command "..m.commandStart..cmd.." issue occured, receipt: ")
end
-- ( Finish Module ) --
return m
