Skip to main content

AttachToInstance

Automatically cleans the vault when the given Instance is destroyed.

const part = new Instance("Part")

vault.AttachToInstance(part)

part.Destroy()

Parameters

ParameterTypeDescription
instanceInstanceInstance whose destruction triggers vault cleanup

Returns

Connection - The Destroying signal connection (auto-added to vault)

Behavior

  • Connects to the instance's Destroying signal
  • When instance is destroyed, automatically cleans the vault
  • Returns the connection for manual management if needed