Require cache

The per-side memory of what each ModuleScript returned, so its body runs once per side.

Think of it as One shared whiteboard per office.

The first require of a ModuleScript on the server (or on one client) runs the module and stores the value it returns. Every later require on that side returns the same value without running the body again. The server, each client and Studio's command bar each have their own cache, so a module required from the command bar is a separate copy.

Where the picture breaks

There is one board per side, not one per game: the server, each client and Studio's command bar each run the module once and hold separate tables.

require caches a ModuleScript's return value per Luau environment. The server, every client and the command bar are separate environments, so state in a module is shared only within one of them. Cross-side data must travel by replication or remotes.

See it with the rest of the analogy cast

Official reference: create.roblox.com

Related terms