Skip to content

Vanguard API Reference

This page lists every public field and method on the main Vanguard module. Concept guides provide deeper examples and behavioral explanation.

Public main-module methods accept both dot and colon syntax:

Vanguard.GetService("InventoryService")
Vanguard:GetService("InventoryService")

Utility object methods use normal colon syntax unless documented otherwise.

Public Fields

Field Runtime Description
Name Both "Vanguard"
Version Both Installed framework version, currently 0.1.15
NetworkProtocol Both Network compatibility version, currently 2
Player Client Players.LocalPlayer
Util Both Folder containing all utility ModuleScripts
Error Both Linked error-code utility; alias of Vanguard.Util.Error
Logger Both Root framework logger
Math Both Number helper utility; alias of Vanguard.Util.Math
Switch Both Case-dispatch utility; alias of Vanguard.Util.Switch
Services Server Service registry
Controllers Client Controller registry
Components Both Component registry
Classes Both Class registry
Plugins Both Plugin registry for the current runtime

Configuration and Startup

Configure

Vanguard.Configure(options: StartOptions?): StartOptions

Merges options and returns the selected configuration. Must be called before Start.

GetConfig

Vanguard.GetConfig(): StartOptions

Returns a shallow clone of selected options.

Start

Vanguard.Start(options: StartOptions?): Promise

Starts the current runtime. Resolves after init hooks, start-hook scheduling, component startup, and readiness. Rejects when called more than once or when init fails.

Bootstrap

Vanguard.Bootstrap(configOrParent: Instance | BootstrapConfig?, options: StartOptions?): Promise

Accepted forms:

Vanguard.Bootstrap(servicesOrControllersFolder, options)

or:

Vanguard.Bootstrap({
    Services = servicesFolder,
    Controllers = controllersFolder,
    Components = componentsFolder,
    Classes = classesFolder,
    Plugins = pluginsFolder,
    Options = options,
})

Server uses Services; client uses Controllers. Plugins load first, then classes, then services/controllers, then components.

OnStart

Vanguard.OnStart(): Promise

Resolves immediately when startup completed or waits for completion.

IsStarted

Vanguard.IsStarted(): boolean

Returns whether startup completed.

Logging and Helpers

CreateLogger

Vanguard.CreateLogger(scope: string?): Logger

Creates a logger using the current configured LogLevel. Default scope is Vanguard.

CreateCache

Vanguard.CreateCache(options: CacheOptions?): Cache

Shortcut for Vanguard.Util.Cache.new(options).

CreateRateLimiter

Vanguard.CreateRateLimiter(options: RateLimiterOptions): RateLimiter

Shortcut for Vanguard.Util.RateLimiter.new(options).

Plugin API

CreatePlugin

Vanguard.CreatePlugin<T>(definition: T): T

Validates and registers a plugin before startup.

RegisterPlugin

Vanguard.RegisterPlugin<T>(plugin: T): T

Registers a plugin table. Re-registering the same plugin is idempotent.

AddPlugins

Vanguard.AddPlugins(parent: Instance): { any }

Loads direct plugin ModuleScript children before startup.

AddPluginsDeep

Vanguard.AddPluginsDeep(parent: Instance): { any }

Loads descendant plugin ModuleScripts before startup.

LoadPlugins and LoadPluginsDeep are aliases.

GetPlugin

Vanguard.GetPlugin(name: string | { Name: string }): PluginDefinition

Returns a registered plugin or throws VG-REG-002.

HasPlugin

Vanguard.HasPlugin(name: string | { Name: string }): boolean

Checks whether a plugin exists in the current runtime registry.

GetPlugins

Vanguard.GetPlugins(): { [string]: PluginDefinition }

Returns a shallow clone of the plugin registry.

UnregisterPlugin

Vanguard.UnregisterPlugin(name: string | { Name: string }): PluginDefinition?

Removes a plugin before startup and returns it when present.

Error

Vanguard.Error.format(code: string, message: string?, cause: any?): string
Vanguard.Error.raise(code: string, message: string?, cause: any?, level: number?)

Formats or throws errors with stable codes and direct documentation links. See the Error Reference.

Math

Vanguard.Math.map(value, inMin, inMax, outMin, outMax, clampResult?)
Vanguard.Math.moveTowards(current, target, maxDelta)

Provides interpolation, range mapping, easing, wrapping, snapping, comparison, and averaging helpers. See Math.

Switch

Vanguard.Switch.new(value):Case(expected, result):Default(result):Run(...)
Vanguard.Switch.match(value, cases, defaultResult?, ...)

Provides ordered builder dispatch and concise direct-map dispatch without fall-through. See Switch.

Update Check

CheckForUpdates

Vanguard.CheckForUpdates()

Server only. Starts the asynchronous configured Wally index check. The normal server startup calls this automatically after readiness when enabled.

Network Information

GetNetworkInfo

Vanguard.GetNetworkInfo(): NetworkInfo

Returns Protocol and ServerVersion. Client fields populate when the remote container is resolved.

GetNetworkStats

Vanguard.GetNetworkStats(): NetworkStats

Server only. Returns cloned accepted/rejected totals, counts by code, and counts by Service.Remote.

ResetNetworkStats

Vanguard.ResetNetworkStats()

Server only. Clears all counters.

Service API

CreateService

Vanguard.CreateService<T>(definition: T): T

Server only. Validates and registers a service before startup. Creates an empty Client table and scoped logger when omitted.

AddServices

Vanguard.AddServices(parent: Instance): { any }

Loads direct ModuleScript children before startup.

AddServicesDeep

Vanguard.AddServicesDeep(parent: Instance): { any }

Loads all descendant ModuleScripts before startup.

LoadServices and LoadServicesDeep are aliases.

GetService

Vanguard.GetService(name: string | { Name: string }): any

Server: returns a registered service after startup begins.

Client: returns or builds a remote service proxy after startup begins.

GetServices

Vanguard.GetServices(): { [string]: ServiceDefinition }

Returns the server service registry after startup begins.

Controller API

CreateController

Vanguard.CreateController<T>(definition: T): T

Client only. Validates and registers a controller before startup and creates its logger when omitted.

AddControllers

Vanguard.AddControllers(parent: Instance): { any }

Loads direct ModuleScript children before startup.

AddControllersDeep

Vanguard.AddControllersDeep(parent: Instance): { any }

Loads all descendant ModuleScripts before startup.

LoadControllers and LoadControllersDeep are aliases.

GetController

Vanguard.GetController(name: string | { Name: string }): any

Returns a registered client controller. Unknown lookup errors with registered names.

GetControllers

Vanguard.GetControllers(): { [string]: ControllerDefinition }

Returns the controller registry after startup begins.

Component API

CreateComponent

Vanguard.CreateComponent(definition: ComponentDefinition | Component): Component

Creates or registers a component. Components created after startup start immediately when StartComponents is enabled.

AddComponents

Vanguard.AddComponents(parent: Instance): { any }

Loads direct ModuleScript children.

AddComponentsDeep

Vanguard.AddComponentsDeep(parent: Instance): { any }

Loads descendant ModuleScripts.

LoadComponents and LoadComponentsDeep are aliases.

GetComponent

Vanguard.GetComponent(name: string | { Name: string }): Component

Returns the named component or errors.

GetComponents

Vanguard.GetComponents(): { [string]: Component }

Returns the component registry.

Class API

CreateClass

Vanguard.CreateClass<T>(definition: T): Class & T

Creates and registers a class. A string Extends field resolves an already-registered parent. Definitions may group instance API in Public, per-instance hidden state in Private, and class-only API in Static.

RegisterClass

Vanguard.RegisterClass<T>(class: T): T

Registers a class created by Vanguard.Util.Class.

AddClasses

Vanguard.AddClasses(parent: Instance): { any }

Loads direct class ModuleScript children.

AddClassesDeep

Vanguard.AddClassesDeep(parent: Instance): { any }

Loads descendant class ModuleScripts.

LoadClasses and LoadClassesDeep are aliases.

GetClass

Vanguard.GetClass(name: string | Class): Class

Returns the registered class or errors.

HasClass

Vanguard.HasClass(name: string | Class): boolean

Checks registry membership by name.

GetClasses

Vanguard.GetClasses(): { [string]: Class }

Returns a shallow clone of the class registry.

UnregisterClass

Vanguard.UnregisterClass(name: string | Class): Class?

Removes and returns the registry entry. Existing instances are unaffected.

Remote Definition API

CreateSignal

Vanguard.CreateSignal(): RemoteSignal

Server definition marker for a reliable bidirectional remote signal.

CreateUnreliableSignal

Vanguard.CreateUnreliableSignal(): RemoteSignal

Server definition marker for an unreliable signal with reliable fallback.

CreateProperty

Vanguard.CreateProperty(initialValue: any?): RemoteProperty

Server definition marker for a server-owned replicated property.

CreateReplicator

Vanguard.CreateReplicator(initialState: any?): Replicator

Server definition marker for a server-owned replicated state tree. Requires network protocol 2. See Replicators.

Module Loading Behavior

Every Add* method:

  1. validates the parent is an Instance;
  2. collects matching ModuleScripts;
  3. sorts by full name;
  4. requires each module inside pcall;
  5. registers the returned definition inside pcall;
  6. logs and skips failures;
  7. returns successful values.

One bad module does not stop the remaining modules from loading.