Attempted to call require with invalid argument(s)

I can’t seem to figure out why this line of code isn’t working

local banned = require(script.Parent:WaitForChild("Settings",10)).BANNED

The module:

local settings = {
    BANNED = {
     	testplayer = true
 	},
}

return settings

When running the game “Settings” is where it needs to be, right under the Server folder

I’m getting this error when BANNED is a clear member of the “Settings” modulescript:

Attempted to call require with invalid argument(s).
4 Likes

Im not entirely sure modules accept waitforchilds as a argument, im on mobile but making it waitforchild before requiring should work

So

Waitforchild
Require(path)

I use this for example

local Settings = require(script.Parent:WaitForChild('Settings')).Variables

Works perfectly fine, try removing the timeout?

3 Likes

I had tried this earlier, but decided to try again just to be sure.

I changed the code to

local bannedd = script.Parent:WaitForChild("Settings",10)
local banned = require(bannedd).BANNED

which still threw the same error

Attempted to call require with invalid argument(s).
2 Likes

Can you try printing bannedd?
Nitefal might be correct on the timeout, you should also try removing it

I’ve always used the timeout to avoid getting the warn, but this seemed to work. Thanks!

3 Likes

You’re welcome.
Here’s the thing, you want that module to load. Always.
Don’t add a timout to it.

It’s still strange though.

3 Likes

10 seconds should be more than long enough, especially during testing…? Odd

2 Likes

Exactly! Even when testing I opened the folder in explorer and sure enough the module was already loaded there before the error was thrown.

It happened to me too, maybe it happens only when the module parent is the same as the script parent, put the module inside the script to test

I had this problem when I accidentally used Script instead of ModuleScript :sweat_smile:

1 Like