API:Class/Selection

Filtered-inheritance mode: While this class technically inherits all Instance class members, some (if not all) have been hidden because they serve no purpose for this object.
Plugin class: This object has been marked as a plugin class. Most if not all of its members are exclusive to the PluginSecurity level.
Service: This class is a service. It is a top-level singleton which can be obtained with the GetService method.

Slectionbox icon.pngSelection : Object Icon.pngInstance

The Selection service helps control the objects that are selected in the 3D view.

Functions

Functions [toggle]

array<Instance>Get ( ) [PluginSecurity]

Returns a table of objects which are currently selected by the user.

|RMD member="API:Class/Selection/Get"|Returns a table of objects which are currently selected by the user.|/RMD|
voidSet ( array<Instance> selection ) [PluginSecurity]

Set's the client's selected objects to all of those in the table.

|RMD member="API:Class/Selection/Set"|Set's the client's selected objects to all of those in the table.|/RMD|
Get ( ) [PluginSecurity]
Returns a table of objects which are currently selected by the user.
Set ( array<Instance> selection ) [PluginSecurity]
Set's the client's selected objects to all of those in the table.


Events

Events [toggle]

SelectionChanged ( )

Fired when the selection in studio changes.

|RMD member="API:Class/Selection/SelectionChanged"|Fired when the selection in studio changes.|/RMD|
Fired when the selection in studio changes.

|RMD member="API:Class/Selection"|The Selection service helps control the objects that are selected in the 3D view. |/RMD|


Example

In Studio or Edit mode, first select some bricks then:

local cf = CFrame.Angles(0, math.pi, 0)
for _, v in ipairs(game.Selection:Get()) do 
  v.CFrame = cf * v.CFrame 
end

Also, you can set which objects are selected with the Set method. So then you can do stuff like select all objects with a certain name, then quickly edit their properties as desired.

local select = {} 
for _, v in ipairs(workspace:GetChildren()) do 
  if v.Name == "Part" then 
    table.insert(select, v) 
  end 
end 
 
game.Selection:Set(select)