cm_an
(cm_an)
#1
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)
Nitefal
(Nitefal)
#3
I use this for example
local Settings = require(script.Parent:WaitForChild('Settings')).Variables
Works perfectly fine, try removing the timeout?
3 Likes
cm_an
(cm_an)
#4
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
cm_an
(cm_an)
#6
I’ve always used the timeout to avoid getting the warn, but this seemed to work. Thanks!
3 Likes
Nitefal
(Nitefal)
#7
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
cm_an
(cm_an)
#9
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
Giorgi311
(Giorgi311)
#12
I had this problem when I accidentally used Script
instead of ModuleScript
1 Like