Skip to content

ModuleLoader

ModuleLoader is the main object returned by the "Modules" ModuleScript. It is designed to replace the built-in require function, retaining all its normal behaviors while also adding more:

  • Call with a string, eg require("Namespace:ModuleName"), to require a Module in a Namespace
  • Call require.server to skip requires if on the client (get nil instead)
  • Call require.client to skip requires if on the server (get nil instead)

Functions

require(object)

The main require overload.

__call(object)

Alias for calling ModuleLoader.require, useful when using ModuleLoader as a require replacement.

server(object)

Like require, but returns nil if not ran on the server.

client(object)

Like require, but returns nil if not ran on a client.

__tostring()

Returns the version of the ModuleLoader being used