Roblox Studio plugin | detecting when something gets selected/unselected

I wanted to create a plugin widget that shows instances that are being selected.
However, I can’t seem to find a way to detect when you select and unselect a selection.

Right now I just have this code on loop, which isn’t very optimized if you decide to select many parts at once.

while wait() do
  for i, v in pairs(Selection:Get()) do
  -- code here
  end
end

I’ve tried to use:

plugin:Activate(true)
plugin:Getmouse().Button1Down:Connect()

but my plugin is meant to work on the side displaying the count live. Since plugin:Activate would force you to be focused on the plugin and nothing else.

Does anyone know a proper way to detect when instances are being selected/unselected without having to use Selection:Get() on loop?

Use Selection.SelectionChanged you can read about it here

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.