API Reference

The complete Component API everything covered across Introduction, Creating a Component and Extensions, gathered in one place.

Methods

Method Description
Component.new(config) Creates a new Component type
Component.CreateExtension(ext) Creates a typed Extension
Component.GetAllOfType(class) Returns every active Component of a class, across Services
:Watch() Starts CollectionService monitoring
:Stop() Stops monitoring and destroys every active Component of this type
:Get(instance) Returns the active Component for an instance, or nil
:GetAll() Returns every currently active Component of this type
:WaitFor(instance, timeout?) Promise, resolves once a Component is ready
.Added Signal - (instance, componentObj)
.Removed Signal - (instance)

Component.new(config) options

Key Type Required Description
Tag string The CollectionService tag this Component watches for
Type "Server" | "Client" | "Shared" Where this Component is active - see Introduction
Ancestors {Instance} Whitelist of ancestors; empty accepts any tagged instance anywhere
Extensions {Extension} Extensions attached to every instance of this Component - see Extensions

.Added / .Removed

Both are ordinary Signals, useful for reacting to a Component appearing or disappearing without polling :GetAll():

EnemyComponent.Added:Connect(function(instance, comp)
    print(instance.Name, "spawned as an enemy")
end)
 
EnemyComponent.Removed:Connect(function(instance)
    print(instance.Name, "is no longer an enemy")
end)

.Added fires after Start() has already run by the time your callback sees the Component, it's fully initialized and safe to call any of its methods on.