GetPropertyChangedSignal should include the new value in the callback


#1

As a developer, it is too hard to not write redundant code with GetPropertyChangedSignal.

With GetPropertyChangedSignal, there aren’t very many scenarios where you wouldn’t want to know what the property actually changed to. For example, if I want to write code that does something when the player’s team changes, I have to write it like this.

LocalPlayer:GetPropertyChangedSignal("Team"):Connect(function()
    local team = LocalPlayer.Team
    --code
end)

I’d much rather simplify this to be…

LocalPlayer:GetPropertyChangedSignal("Team"):Connect(function(team)
    --code
end)

#4

I’d prefer it to include the new and the old value, much like StateChanged from Humanoid.

So more like…

LocalPlayer:GetPropertyChangedSignal("Team"):Connect(function(old, new)
    print(LocalPlayer,"switched from team", old, "to team", new);
end);

#5

Bumping this thread since I really would appreciate this

If I want to do something like

part:GetPropertyChangedSignal("Position"):connect(function()

end) 

In order to get the last and new position I have to keep track of the change myself, which is pretty annoying


#6

I believe it was implemented like this because serializing the value for Lua could be non-trivial and slow down the signal significantly for cases that don’t need it.


#7

Although the creation of functions with extra upvalues can also be expensive (at least the first time).


#8

This would make development a whole lot more convenient