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

Are module scirpts local or server sided?

2 scenarios:

  1. A local script calls the function inside the module script. Is that function local or server?
  2. A local script sends a remoteevent to a server script, server script calls the function inside the module script, server or local?

3 comments

0

scirpts

0

It depends on the type of script that is requiring it. ModuleScripts adopt the script type of the requiring script, so that means you can call LocalScript-only paths (like LocalPlayer) if required by a LocalScript. You can access the ServerStorage and ServerScriptService if required by a Server Script.

0

ModuleScripts inherit the context level of the script that requires them

3 answers

ModuleScripts have no side in the Client-Server model by default, they run inside the context that they are required in.

Whenever you require a ModuleScript, you should imagine it being run inline in that very location.

With this in mind, if you plan on only requiring a ModuleScript from a LocalScript, you could use Client-side services like UserInputService within your ModuleScript. Similarly, if you only require a ModuleScript from a Script, you would be able to manipulate objects within ServerStorage from your ModuleScript.

However, some people create Utility Modules that can be required by both a Client and the Server. This is achieved by the ModuleScript being located in ReplicatedStorage, and also it not containing any code that is side specific.

They are both sided, though, if I remember correctly, if you changed data of a module script on a server script, it won't replicate to the client, meaning the changes won't apply to the client.Same thing for the client, if a module script is changed on the client, it will stay the same on the server side

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