ModuleScript
Executes Luau on first require and caches its return value.
- Creatable
Instance.new("ModuleScript")- Inherits
- LuaSourceContainerInstance
- Replication
- Standard
Behavior
ModuleScript executes when required and caches its first return value. Caches
are scoped to the execution group and Luau VM. Server and client caches are
separate. An absent or nil return value is cached as true.
Modules in ReplicatedStorage are readable by clients.
Use ServerStorage for server-only modules. Circular
requirements raise cyclic ModuleScript require.
Summary
The Luau text of the module.
Returns this instance if it is an ExecutionGroup.
Returns the script instances available through this script binding.
Properties
Source
ModuleScript.Source: string = ""The Luau text of the module.
Methods
GetExecutionGroup
ModuleScript:GetExecutionGroup(): ExecutionGroup?Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.
GetScripts
ModuleScript:GetScripts(): tableReturns the script instances available through this script binding.
Inherited members
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying
Example
-- ModuleScript named Configuration.
return { RoundDuration = 60 }