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

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

Asked by 5 years ago
Edited 5 years ago

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!

0
Put the code in code blocks... Prestory 1395 — 5y
0
Yes sorry, I meant to do that it blocked the wrong things. Pizzafireme 14 — 5y
0
settingsmodule is the config table, so you are essentially doing config.config.Admins theking48989987 2147 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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
0
Ah, I see. Thank you. Pizzafireme 14 — 5y
Ad

Answer this question