Hey there! Right now, I’m trying to create an admin system in which all of the commands are in their own module script and are required by the MainModule.
At the current moment, it’s not working because I’m trying to concatenate the arguments table into its own thing so that data from it can be passed to the client, but it’s not working. Here’s the error I get when I try doing it:
It looks like Arguments is in a dictionary. To retrieve its value, you should write require(v)["Arguments"]
I can’t see your full module script so correct me if I’m mistaken.
I don’t think it would make a difference as what I’m showing you is pretty self explanatory. The MainModule is looping through the commands and then creating a value in a folder that will let the client + server view the commands. The Module Script here is the command, which should return the arguments, but table.concat isn’t working on it, even though I’ve checked that it returns.
You shouldn’t require it 4 times like that, especially in a loop. It’s very inefficient. First thing I’d do to debug this is at the top of the for loop:
local mod = require(v)
print(mod)
Just to see what’s causing this.
I’d also keep mod afterwards so you don’t require it 4 times.
While it didn’t work when I did what you asked, I put it in a pcall w/ the name of script it errored on, and learned that I just did that one script wrong. Thank you so much for your help!
That’s one way to do it. It seems that you’re looping over a few different modules, and expecting them to have the same structure.
That error is telling me that one or more of the modules you’re looping over doesn’t have the “Arguments” key in its returned table.
You should implement checks to ensure the module returns what you expect it to, for example:
for ... in pairs(...) do
local myModule = require(v)
-- if the module doesn't return a table, skip to the next item in the loop
if type(myModule) ~= "table" then
continue
end
-- if the module contains a key, "Arguments," and it's a table...
if type(myModule.Arguments) == "table" then
local concatData = table.concat(myModule.Arguments, " | ")
-- do stuff
end
end
Just thought I’d provide you with an explanation as to why you were getting that error. Obviously if you found a way that works for you, stick with it!
If you had posted that before I realized how to do it, it would’ve done the trick and would’ve shown me what I’ve done. Again, thank you so much for trying to help me!