Construct
Creates an instance of a class and automatically adds it to the Vault.
- TypeScript
- Luau
const part = vault.Construct(Instance, "Part")
part.Parent = workspace
const tool = vault.Construct(() => new Instance("Tool"))
vault.Clean() // Cleans both instances
local part = vault:Construct(Instance, "Part")
part.Parent = workspace
local tool = vault:Construct(function()
return Instance.new("Tool")
end)
vault:Clean()
Parameters
| Parameter | Type | Description |
|---|---|---|
classOrConstructor | Constructor<T, A> | () -> T | Class or factory function |
...args | A | Arguments 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