Where to Put a ModuleScript in Roblox: ReplicatedStorage, ServerScriptService, or ServerStorage
Choose a ModuleScript's location according to whether the server, clients, or both need access to it.

Placement guide
RequirementLocation
Server and client scripts both require the moduleReplicatedStorage
Only server scripts require the moduleServerScriptService
A server ModuleScript is stored with other server-only objectsServerStorage
`ReplicatedStorage` contains objects available to the server and connected clients. Roblox typically uses it for ModuleScripts shared by server Scripts and client scripts.

ServerScriptService contains server-only scripting objects, including ModuleScripts required by server scripts, and its contents are never replicated to clients. ServerStorage also contains server-only objects. Scripts do not run while parented there, but scripts in ServerScriptService can access and run ModuleScripts stored there.

Keep trusted logic on the server

Because clients receive the contents of ReplicatedStorage, it is not a private location. Keep server-only logic in a server-only container. Roblox also requires the server to validate data sent by clients before using it.

How require() behaves

A ModuleScript runs once when first required and returns the same reference to later require() calls in the same environment. When the same ModuleScript is required on both sides of the client-server boundary, it returns a unique reference for each side.

Roblox identifies WaitForChild() as an important safety measure when client scripts access replicated objects:

Code: Select all

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SharedModule = require(ReplicatedStorage:WaitForChild("SharedModule"))
Practical rule

Use ReplicatedStorage for modules intentionally shared with clients, ServerScriptService for server-only scripting logic, and ServerStorage when a server ModuleScript is kept with other server-only stored objects.