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

Help Me: Module Configuration Help?

Asked by 5 years ago
Edited 5 years ago

Basically I have a loader that has multiple configuration tables inside of it. Here's my code from my script that grabs the configuration:

nil
--Stop trying to get my source! Thanks.

On the "local Configuration" line of code, I get an error saying:

nil
--Stop trying to get my source! Thanks.

Here's the return line of my configuration module:

nil
--Stop trying to get my source! Thanks.

Is there supposed to be like a wait() function so it can load properly or something? Since this part errors the rest of my scripts don't work as they are dependent on the configuration.

1 answer

Log in to vote
1
Answered by
xPolarium 1388 Moderation Voter
5 years ago

On the ModuleScript you're returning 11 values back to the local Configuration variable in your first code block. One variable wont be able to store all of those hence the error. You could instead return the table of the ModuleScript (Which is what its for) and then index the value you want.

So this is how your module script should look like:

local myTable = {
    myFirstValue = 3,
    mySecondValue = 4
}

return myTable --Return the table instead of the individual values

In your script you would require the ModuleScript then be able to grab the value just by using the variable you defined.

local myModuleScript = require(game.ReplicatedStorage.ModuleScript)

print(myModuleScript.myFirstValue) --prints 3

Simplest way of using ModuleScripts and you can even do more with them.

Let me know if need more of an explanation.

0
So I'm removing all my old tables and making it one big one? Chaddaking 60 — 5y
0
If that's how it is on your ModuleScript then yes. xPolarium 1388 — 5y
Ad

Answer this question