Unable to require ModuleScript from Script

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

I expect that this is a client script, client-sided scripts cant access ServerScriptService or ServerStorage.

As I said, its a server script.

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.

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)

There is no loops. Just functions.

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.

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

The script exists at the time it’s being called. Otherwise it would be throwing an error.

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?

Well, its not working. No warning/error.

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?

Probably untoggled either options to show warnings/errors.

Just a module for handling halos in my game.

Everything is toggled on. chars

I’ve tried that. It does not print anything.

Does the UImodule return? It might get stuck on that line. Just try commenting that line out and see if it works.

Strange, but when I commented line that requires UIModule, my code started to work. What does “does UIModule return” means?