How to keep an object selected when pressing a button in a plugin?

I am busy making a plugin which requires you to select an object then click a button on the plugin, when you do this the object gets unselected.

I tried holding shift then clicking but this causes a weird bug, which I would report on studio bugs but I can’t.

How can I keep the object selected while clicking the button on the plugin?

Can you elaborate on how the instance gets unselected? Are you using Selection:Get() and then remove the object from the table?

When you have an object selected and click away it gets unselected, it happens before the Selection:Get() is called:
https://i.gyazo.com/3c0a798f8ddeeede16db4eec4c22c1c7.mp4

So I found a fix to this by using Selection.SelectionChanged