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

Are you able to send tables when requiring a ModuleScript?

Am I able to send tables, when I require a module in my inventory. I keep getting an error saying, "ServerScriptService.Script:7: attempt to call a number value"

local settings = {
	groupId = 0;
	minStaffRank = 0;
	minAdminRank = 0
}
	
require(1913364255)(settings)

1 comment

0

Yes, you can. It may be another script in your module or something.

1 answer

✓ Accepted answer

If you meant returning a table, yes, you can simply return a table from your ModuleScript. Since table values are of reference type, and module return values are cached, every time you require the module, a reference to the same table will be returned.

If you want to send a table to a ModuleScript via a function it returns, I recommend returning a function that takes a table as an argument, and operates on that, but that's not particularly useful, and limits how other scripts and modules can interact with your module. Instead, I recommend passing data the module needs as arguments to functions, and returning a dictionary of functions from your module.

In your case, you are attempting to call a function that the module returns, but it returns a number, and this isn't what you want. Additionally, I recommend against requiring modules by ID, it's much better to insert them into Studio and require them by their instance.

1 comment

0

Have I figured out what I did wrong. Thank you though for the help!

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