When someone connects to .Changed, they rarely need to connect to every single property. The way .Changed is set up closes doors for potential C++ optimizations, where some properties might only need constant updating if someone is listening to or getting the value. The number of unnecessary function calls can be massive.
Pretty much every time .Changed is used, it will look something like this:
part.Changed:connect(function(property)
if property == "BrickColor" then
-- stuff
end
end)
I think the problem is in how events/signals are set up. Currently, we have RBXScriptSignals, but there are plenty of features that would benefit from a specialized signal type. Here are some rough ideas:
###Instance.Changed
part.Changed:connectProperty(“BrickColor”, function()
– stuff
end)
RunService.BindToRenderStepped
If something can be disconnected from, or “unbound” then it should always return a connection.
local priority = Enum.RenderPriority.Input.Value
game:GetService("RunService").RenderStepped:connectPriority(priority, function(delta)
-- stuff
end)
###ContextActionService.BindAction
User input is tricky, not sure how to improve this one, but it’s related.
game.OnClose
This is a problem for an analytics module I’ve been working on, because it’s not possible for multiple scripts to connect to this.
Ideally, multiple scripts would be able to connect, and when the game closes, the connected functions would all be called, and the game would close once all of them are finished.
game.Closing:connect(function()
wait(1)
end)