Skip to main content

OnChanged

Connects to property changes on instances or Seam states.

TypeSinceScoped
Connection0.0.1Yes

Constructors​

Embedded in New:

[OnChanged] = (PropertyName : string, NewValue : any) -> ()

Standalone:

OnChanged(Object : Instance | State, Callback : (PropertyName : string, NewValue : any) -> ()) -> RBXScriptConnection

Usage​

Works with anything that exposes a .Changed signal and readable properties — including Seam states.

New("Frame", {
[OnChanged] = function(PropertyName, NewValue)
print(PropertyName, NewValue)
end,
})

Standalone on a state:

local MyValue = Value(0)

local Connection = OnChanged(MyValue, function(PropertyName, NewValue)
print(PropertyName, NewValue) -- "Value", 1
end)

MyValue.Value = 1
Connection:Disconnect()

For instances, this is equivalent to Instance.Changed with the new property value passed as the second argument.