Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with my module script, It doesn't load when I require it?

Asked by
Lualaxy 78
5 years ago

So I have a module script what just doesn't want to work. When I require it it just says: 15:02:17.983 - Requested module experienced an error while loading
15:02:17.984 - Stack Begin
15:02:17.984 Script ‘ServerScriptService.SkullAdmin’, Line 1
15:02:17.985 - Stack End

In the admin there is only require(script.adminCommands) to require the module script.

So this is the module script: (What is wrong?)

local m = {}



-- Setup Events

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

player.Chatted:Connect(function(msg, r)

if r then return

end

m.parse(msg, player)

end)

end)



-- Services



local dstore = game:GetService("DataStoreService")





-- Setup Variables

m.database = dstore:GetDataStore("adminCommands")

m.adminList = {

"SkullMasterHD";

}

m.prefix = "?"



-- Database Check

local aList -- Admin List

pcall(function()

aList = m.database:GetAsync("adminList")

end)



if not aList then

m.database:SetAsync("adminList", m.adminList)

aList = m.adminList

end



-- Parse Function



function m.parse(msg, player)

local playerisAdmin

for a,b in pairs(aList) do

playerisAdmin = b == player.Name

if playerisAdmin then break end

end

if playerisAdmin then

if msg:sub(1,1) == m.prefix then

if #msg == 1 then

warn("Only prefix added. Concider inputting a command after. ")

else -- Parse rest

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 Exist

warn("There is no such Command as" ..command.. "stored.")

end

end

end

end

end



-- Commands

m.commands={

addAdmin = function(arg, caller)

for a,b in pairs(arg) do

if tostring(b) then

print(b .. "has been added as an Admin!")

table.insert(aList,tostring(b))

m.database:SetAsync("adminList", aList)

else

local username = game.Players:GetNameFromUserIdAsync(b)

if username then

table.insert(aList, username)

print(b .. "has been added as an Admin!")

table.insert(aList,username)

m.database:SetAsync("adminList", aList)

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 tostring(b) then

print(b .. "has been removed from the Admin list.")

for d,c in pairs(aList) do

if c == tostring(b) then

table.remove(aList,d)

break

end

end

m.database:SetAsync("adminList", aList)

else

local username = game.Players:GetNameFromUserIdAsync(b)

if username then

print(b .. "has been removed from the Admin list.")

for d,c in pairs(aList) do

if c == username 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;

testwork=function(arg, caller)

for a,b in pairs(arg) do

print("Admin is Installed and working")

end

end;

}





-- Custom Warn Function



function m.warn(cmd, issue)

warn("In command " .. m.prefix .. cmd .." issue occured, receipt: " .. issue)

end



-- Finish

return m
0
Error in module SoftlockedUnderZero 668 — 5y
0
Where... Lualaxy 78 — 5y
0
When you require the module, use ':WaitForChild'. Sometimes it can't find the module because it doesn't exist. SaltyIceberg 81 — 5y
0
Nothing here worked yet... Lualaxy 78 — 5y

Answer this question