Recently I tried to make a custom admin script. I made it in a module Script inside of a script in ServerScriptService. There was no errors and within the past few hours, I was finishing up and doing the final line in the script “require(script.adminCommands)”.
There was no “errors” so to speak, however it said that the requested module experienced an error while loading. I’ve spent a few hours trying to get a fix, (looking through my script to see if there’s any errors, making sure the logic works, etc) however I can’t find anything.
Can I please get some help with this? If you can help it’ll be greatly appreciated.
I tried that, however, because of the way the script works (It returns the table which holds the commands, functions, etc) I can’t really set breakpoints as it’ll always fire the require function.
--Variables
local m = {}
local Datastore = game:GetService("DataStoreService")
--Functions
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg,r)
if r then return end
end)
end)
--Table stuff
m.database = Datastore:GetDataStore("CoolAdminCommands")
m.adminList = {
41353321;
-1;
}
m.commandStart=":"
--Checking stuff
local List
pcall(function()
m.database:GetASync("adminList")
end)
if not List then
m.database:SetAsync("adminList", m.adminList)
List = m.adminList
end
--Doing some more stuff
function m.parse(msg,player)
local playerIsAdmin
for a,b in pairs(List) 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
print("Just command start you silly goose")
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
if m.commands[command] then
m.commands[command](arguments,player)
else
print("No command titled"..command.."exists")
end
end
end
end
end
end
m.commands = {
addAdmin = function(arg,caller)
for a,b in pairs(arg) do
if tonumber(b) then
print("Added admin"..b)
table.insert(List,tonumber(b))
m.database:SetAsync("adminList", List)
else
local userid = game.Players:GetUserIdFromNameAsync()
if userid then
print("Added admin"..b)
table.insert(List,userid)
m.database:SetAsync("adminList",List)
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("Added admin"..b)
for d,c in pairs(List) do
if c == tonumber(b) then
table.remove(List,d)
break
end
end
m.database:SetAsync("adminList",List)
else
local userid = game.Players:GetUserIdFromNameAsync()
if userid then
for d,c in pairs(List) do
if c == userid then
table.remove(List,d)
break
end
end
m.database:SetAsync("adminList",List)
else
m.warn("addAdmin", "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
}
--Even more stuff
function m.warn(cmd, issue)
print("In command "..m.commandStart..cmd.." issue occured, receipt: "..issue)
end
return m
The issue is somewhere at the top of your script. I threw this code raw into a new place file and tried running it; surely enough, I got the same error. After I began to add prints to the code to set up a form of benchmarks, I noticed that some of the prints were not running. Specifically at the top.
Note: there were a few spelling and conventional mistakes, which I corrected.
The code within the blue square is where the issue is occurring. I haven’t worked towards a solution regarding this chunk yet, though something here is not going as intended. Precisely, it’s refusing to even enter beyond the SetAsync statement.