Bulk-process selection-related operations on instances - Do not fire SelectionChanged for every instance in a mass-delete

When you delete a selection containing multiple instances in Studio, SelectionChanged will fire once for each individual instance you have selected.

This is a major performance gotcha for plugins, is completely unexpected and does not make sense, and requires I write code to wait until the next heartbeat before processing the selection, rather than doing it when the selection actually changes. This results in messy code and is an unexpected source of severe performance issues, which I ran into here: Studio Tweaks - Disable selection box, disable UI Editor, anchor new parts, show selection faces, and more - #76 by sozzly

To demonstrate, create a 5x5 grid of parts in studio, select them all, and run game.Selection.SelectionChanged:Connect(function() print(game.Selection:Get()) end) in the command bar. Delete them and see 25 prints.

Roblox Studio should not be doing dumb processing “one-at-a-time” for operations that execute in bulk over selected instances. It should be handling this case in a special way so it only needs to fire related events once, when the operation is complete.

Related:

8 Likes