Admin Script (Arceus) failing to pair Owners table

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

It would be helpful if you highlighted line 46 where the error took place. Is it the function* within the module itself?

Ok, will do. It’ll say – Marked

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 = {},

	DataKey = "", -- Removed for security
	UseHttp = true
}

It’s not formatting for some reason.

Oh its the parameter didn’t spot that my bad… Have you printed settings to see how it looks? if that is it above shouldn’t your have loop ran?

… you… can’t print… a table?
I have it right here, I can just look at that.

Ofc you can print a table :man_facepalming: that feature was added so long ago


If you mean {…} (what it returns) then you’re right, but that doesn’t even work.
Nevermind, I’m supposed to click.

Anyways, how do I fix this?

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

image

Show tables expanded by default

oh nvm

Read edit. How do I fix the error?

Not sure what the error is all you described was “Run” is there something other than that.

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

table expected, got nil
Is what it says did you print settings or the table you were attempting to index

else
print(Settings,Settings["Owners"])
		for i,v in pairs(Settings["Owners"]) do -- Marked

It is trying to tell you that Settings[“Owners”] == nil

Sorry, I marked the wrong part.

-- 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

So print Owners

print(Owners) --// Output said it printed nil so problem is that Owners == nil
for i,v in pairs(Owners) do -- Marked

-Smashes head on keyboard-
I ALREADY KNOW WHAT OWNERS IS!
IT’S JUST MY USERNAME!

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. :pensive:

I’m having a stroke reading this. I know what the tables are, and you haven’t helped that much. You’ve told me that true = false, basically.

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.

2 Likes