Skip to main content

OnAttached

Used to track attribute changes in states or instances

TypeSinceScoped
Connection0.3.3Yes

Constructor

OnAttached(State : any, Callback : (AttachedInstance : Instance) -> nil)

Usage

OnAttached is a highly specific connection that allows you to connect to when states attach to instances with New.

It works like this:

local New = Seam.New
local Value = Seam.Value
local OnAttached = Seam.OnAttached

local MyState = Value(Color3.fromRGB(255, 0, 0))

OnAttached(MyState, function(AttachedInstance)
print("Attached to: " .. AttachedInstance.Name)
end)

local MyInstance = New("Part", {
Color = MyState -- Because we set Color to MyState, OnAttached triggers and prints "Attached to: Part"
})