An update to .Changed

I think it’d be neat to add two extra arguments to .Changed

event Changed(propertyName, oldValue, newValue)

1 Like

The Change event wouldn’t know what properties to return in the arguments, I don’t think it would work.

This would be problematic in some cases.

  1. Sometimes the engine fires changed events without there really being an obvious “new” or “old” value, in order to satisfy some more hairy parts of the API around the humanoid and character in particular.

  2. It would also increase the cost of the API significantly, because the engine would have to bridge across the new and old values every time a changed event came up, even if you did not need them. For instance, this would mean if you were doing something like listening on TextGui object for .Changed with property == Text, now every single time that TextGui’s Position or Size changes, the .Changed even has to bridge across a bunch of UDim2 and Vector2 values to represent those things even when your code is not ever going to use them.

I suspect that that’s why the .Changed event was not originally given new and old values in the first place when the Roblox API was initially designed, because it makes it significantly more expensive to listen on changed events of objects that have a lot of changing properties when you only actually need some of them.