Skip to main content

Construct

Creates an instance of a class and automatically adds it to the Vault.

const part = vault.Construct(Instance, "Part")
part.Parent = workspace

const tool = vault.Construct(() => new Instance("Tool"))

vault.Clean() // Cleans both instances

Parameters

ParameterTypeDescription
classOrConstructorConstructor<T, A> | () -> TClass or factory function
...argsAArguments to pass to constructor

Returns

T - The constructed instance (auto-added to vault)

Behavior

  • Supports both class constructors and factory functions
  • Automatically adds the created object to the vault
  • Returns the created instance for immediate use