Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why do I get an error when trying to require a ModuleScript from ServerScriptService?

Asked by 5 years ago

When I try to require a ModuleScript from a folder in ServerScriptService, it gives me the following error: Modules is not a valid member of ServerScriptService

"Modules" is the name of the folder and i'm trying to access it using the following code in a local script in StarterGui:

local eai = require(game.ServerScriptService.Modules.Classes.Enemy.EnemyAi)

Please forgive me if this is a very simple solution, it has been a very long time since i last programmed on ROBLOX and I have forgotten quite an amount of stuff

Thanks

0
Is this in a local script? If so local scripts cant index the ServerScriptService. Anything inside of ServerStorage and ServerScriptService are accessible from server scripts only vamps108 0 — 5y
0
he even said it Luka_Gaming07 534 — 5y
0
Is there any way I can access it using a local script? Godlydeathdragon 227 — 5y
0
read answer Luka_Gaming07 534 — 5y
0
no there is not godly, you have to move it somewhere that a local script can access Gameplayer365247v2 1055 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

Put the modules in ReplicatedStorage

0
Thanks, that worked. Can't believe i spent so much time trying to figure out such a dumb mistake.. Godlydeathdragon 227 — 5y
Ad
Log in to vote
1
Answered by
xdeno 187
5 years ago

The Client can't see ServerScriptService, hence why Server is in the name. You are getting the error because to the Client the Module doesn't exist.

You must move the Module into a place where the Client can see it, for example ReplicatedStorage.

You can then access the Module via a LocalScript as the Client can now see it.

0
Thanks for the explanation, but someone else already answered before you in a similar way Godlydeathdragon 227 — 5y
0
Yea, I was explaining why you got the error which was your question. xdeno 187 — 5y

Answer this question