Alright, as you could read by the title, I’m developing an admin named Arceus (Arceus Admin) but I couldn’t figure out why this errored: Line 46 in function “Run”.
P.S; This is a module.
-- Arceus Loader
local Admin = {}
local Services = {
Players = game:GetService("Players"),
ScriptService = game:GetService("ServerScriptService"),
ReplicatedStorage = game:GetService("ReplicatedStorage"),
DataStore = game:GetService("DataStoreService")
}
function Admin.Run(Settings)
local AutoConfig = Services["DataStore"]:GetDataStore(Settings["DataKey"])
local Owners = {}
local Admins = {}
local Moderators = {}
if Settings["AutoConfigure"] == true then
if AutoConfig:GetAsync("Exists") == false then
AutoConfig:SetAsync("Exists",true)
AutoConfig:SetAsync("Owners",Settings["Owners"])
AutoConfig:SetAsync("Admins",Settings["Admins"])
AutoConfig:SetAsync("Moderators",Settings["Moderators"])
end
Owners = AutoConfig:GetAsync("Owners")
Admins = AutoConfig:GetAsync("Admins")
Moderators = AutoConfig:GetAsync("Moderators")
else
for i,v in pairs(Settings["Owners"]) do
table.insert(Owners,v)
end
for i,v in pairs(Settings["Admins"]) do
table.insert(Admins,v)
end
for i,v in pairs(Settings["Moderators"]) do
table.insert(Moderators,v)
end
end
local LoaderScript = script.ArceusAdmin:Clone()
LoaderScript.Parent = Services["ScriptService"]
LoaderScript.DataKey.Value = Settings["DataKey"]
LoaderScript.UseHttp.Value = Settings["UseHttp"]
for i,v in pairs(Owners) do -- Marked
local Value = Instance.new("StringValue",LoaderScript.Owners)
Value.Name = v
Value.Value = v
end
for i,v in pairs(Admins) do
local Value = Instance.new("StringValue",LoaderScript.Admins)
Value.Name = v
Value.Value = v
end
for i,v in pairs(Moderators) do
local Value = Instance.new("StringValue",LoaderScript.Moderators)
Value.Name = v
Value.Value = v
end
LoaderScript.Disabled = false
end
return Admin
I’ve been reading and I’m just looking at* things like you call this dictionary Settings a lot but I don’t see it defined anywhere have you tried printing i recommend placing one here.
else
print(Settings)
for i,v in pairs(Settings["Owners"]) do -- Marked
Settings is found at the Run function, here is an example:
local Settings = {
AutoConfigure = true, – Sets up DataStore automatically
Owners = {“iiDkOffical”},
Admins = {},
Moderators = {},
Theres like a triangle face it which you can select to open like the brackets in explorer also theres a setting to enable to do it automatically if you like
Read title.
ServerScriptService.Script.MainModule:46: invalid argument #1 to ‘pairs’ (table expected, got nil) - Server - MainModule:46
11:33:12.186 Stack Begin - Studio
11:33:12.186 Script ‘ServerScriptService.Script.MainModule’, Line 46 - function Run - Studio - MainModule:46
11:33:12.186 Script ‘ServerScriptService.Script’, Line 11 - Studio - Script:11
11:33:12.186 Stack End - Studio
-- Arceus Loader
local Admin = {}
local Services = {
Players = game:GetService("Players"),
ScriptService = game:GetService("ServerScriptService"),
ReplicatedStorage = game:GetService("ReplicatedStorage"),
DataStore = game:GetService("DataStoreService")
}
function Admin.Run(Settings)
local AutoConfig = Services["DataStore"]:GetDataStore(Settings["DataKey"])
local Owners = {}
local Admins = {}
local Moderators = {}
if Settings["AutoConfigure"] == true then
if AutoConfig:GetAsync("Exists") == false then
AutoConfig:SetAsync("Exists",true)
AutoConfig:SetAsync("Owners",Settings["Owners"])
AutoConfig:SetAsync("Admins",Settings["Admins"])
AutoConfig:SetAsync("Moderators",Settings["Moderators"])
end
Owners = AutoConfig:GetAsync("Owners")
Admins = AutoConfig:GetAsync("Admins")
Moderators = AutoConfig:GetAsync("Moderators")
else
for i,v in pairs(Settings["Owners"]) do
table.insert(Owners,v)
end
for i,v in pairs(Settings["Admins"]) do
table.insert(Admins,v)
end
for i,v in pairs(Settings["Moderators"]) do
table.insert(Moderators,v)
end
end
local LoaderScript = script.ArceusAdmin:Clone()
LoaderScript.Parent = Services["ScriptService"]
LoaderScript.DataKey.Value = Settings["DataKey"]
LoaderScript.UseHttp.Value = Settings["UseHttp"]
for i,v in pairs(Owners) do -- Marked
local Value = Instance.new("StringValue",LoaderScript.Owners)
Value.Name = v
Value.Value = v
end
for i,v in pairs(Admins) do
local Value = Instance.new("StringValue",LoaderScript.Admins)
Value.Name = v
Value.Value = v
end
for i,v in pairs(Moderators) do
local Value = Instance.new("StringValue",LoaderScript.Moderators)
Value.Name = v
Value.Value = v
end
LoaderScript.Disabled = false
The script is telling the exact opposite that it doesn’t even exist. But I recently discovered that printing tables is a beta feature my bad you will have to active the beta feature. Not sure if is released or not.
But the script is telling you otherwise.Its not about what you already know its about the script is doing and it says its erroring.Would you like help or not.
The part that assigns the Owners table, the AutoConfig:GetAsync is returning nil, hence you’re trying to loop through nil which is giving you an error.