Hi. This can be achieved via the Selection service and it’s Get method. The Get method of the Selection service returns an array of instances currently selected.
Example
-- Studio user selects the Workspace
local selection = game:GetService("Selection")
local current = selection:Get()[1]
print(current.Name) -- Workspace
Likewise, the Set method might be useful if you want to set the currently selected items.
Example
-- Studio user selects the Workspace
local selection = game:GetService("Selection")
selection:Set({game.ReplicatedStorage})
local current = selection:Get()[1]
print(current.Name) -- ReplicatedStorage
Keep in mind that both methods are PluginSecurity and cannot be used in normal Scripts and LocalScripts (and module scripts required from Scripts and LocalScripts. They can be used in a ModuleScript if required from a plugin script)