Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

5 comments

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

0

he even said it

0

Is there any way I can access it using a local script?

0

read answer

0

no there is not godly, you have to move it somewhere that a local script can access

2 answers

✓ Accepted answer

Put the modules in ReplicatedStorage

1 comment

0

Thanks, that worked. Can't believe i spent so much time trying to figure out such a dumb mistake..

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.

2 comments

0

Thanks for the explanation, but someone else already answered before you in a similar way

0

Yea, I was explaining why you got the error which was your question.

This discussion is preserved as it was. New answers, comments, and votes are closed.