NeoBuilds
(NeoBuilds)
March 26, 2022, 3:54pm
#1
So I’ve been making a new module for my game and it looks like I can’t require it from server script. If I run this code:
local ServerScriptService = game:GetService("ServerScriptService")
print(0)
local Module = require(ServerScriptService.Modules.Module)
print(1)
It only prints 0.
1 Like
KJry_s
(MalleoZephyris)
March 26, 2022, 3:59pm
#2
I expect that this is a client script, client-sided scripts cant access ServerScriptService or ServerStorage.
NeoBuilds
(NeoBuilds)
March 26, 2022, 3:59pm
#3
As I said, its a server script.
tlr22
(FusionOak)
March 26, 2022, 3:59pm
#4
What is running in the module script. If it doesn’t return, then it won’t finish the require. So if you made an infinite loop it would get stuck.
KJry_s
(MalleoZephyris)
March 26, 2022, 4:01pm
#5
Then you should use :WaitForChild(), as this is the start of the script, so ServerScriptService did not load.
local ServerScriptService = game:GetService("ServerScriptService")
print(0)
local Module = require(ServerScriptService:WaitForChild("Modules"):WaitForChild("Module"))
print(1)
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:02pm
#6
There is no loops. Just functions.
tlr22
(FusionOak)
March 26, 2022, 4:02pm
#7
Throw a print right at the top of the module script, and a print right before it returns. And see if both of those print.
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:03pm
#8
You should not use WaitForChild in this case. If it was the case, it would’ve thrown error.
try this
local Module = require(ServerScriptService:WaitForChild("Modules").Module)
print(1)
if that doesn’t work send an image of the workspace of the serverscriptservice and the modules
tlr22
(FusionOak)
March 26, 2022, 4:04pm
#10
The script exists at the time it’s being called. Otherwise it would be throwing an error.
KJry_s
(MalleoZephyris)
March 26, 2022, 4:04pm
#11
It still throws a warning, try and use it before saying it is bad, you can always make your own error system on it instead of keeping it warnings.
Can you send us the code for the module you’re trying to require?
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:05pm
#13
Well, its not working. No warning/error.
tlr22
(FusionOak)
March 26, 2022, 4:05pm
#14
Have you tried putting a print at the top of the module script and the print right before the return statement of the module script to ensure that they both print?
KJry_s
(MalleoZephyris)
March 26, 2022, 4:05pm
#15
Probably untoggled either options to show warnings/errors.
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:07pm
#16
Just a module for handling halos in my game.
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:08pm
#17
Everything is toggled on. chars
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:08pm
#18
I’ve tried that. It does not print anything.
tlr22
(FusionOak)
March 26, 2022, 4:09pm
#19
Does the UImodule return? It might get stuck on that line. Just try commenting that line out and see if it works.
NeoBuilds
(NeoBuilds)
March 26, 2022, 4:11pm
#20
Strange, but when I commented line that requires UIModule, my code started to work. What does “does UIModule return” means?