Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get a value from a module script? What am I doing wrong?

Alright, I'm working on a sort of admin panel, I have a configuration module script though when I try to get a value from it I get the following error:

ServerScriptService.ModPanelSever:6: attempt to index field 'config' (a nil value)

Here is my main script;

local settingsmodule = require(game.ServerScriptService.ModConfiguration)
game.Players.PlayerAdded:Connect(function(player)
	for i,v in pairs(settingsmodule.config.Admins) do
		print(v)
		if player.Name == v then
			local value = Instance.new("BoolValue",player)
			value.Name = "AdminValue"
			value.Value = true
			print("yes")
		end
	end
end)

Here is the script in the configuration module script;

local config = {
	Admins = {"mobbySlayin","Pizzafireme"}; -- Everyone you want as a normal admin
}
return config

I'm not quite sure what I'm doing wrong, any help would be much appreciated!

3 comments

0

Put the code in code blocks...

0

Yes sorry, I meant to do that it blocked the wrong things.

0

settingsmodule is the config table, so you are essentially doing config.config.Admins

1 answer

✓ Accepted answer

settingsmodule is the config table, so you are essentially doing config.config.Admins -theking48989987

Basically, you just have to do:

local admins = require(game.ServerScriptService.ModConfiguration).Admins

1 comment

0

Ah, I see. Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.