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

Help Me: Module Configuration Help?

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

✓ Accepted answer

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.

2 comments

0

So I'm removing all my old tables and making it one big one?

0

If that's how it is on your ModuleScript then yes.

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