Service · inherits Instance
Selection
The Selection service controls the Instances that are
selected in Roblox Studio.
About Selection
The Selection service controls the Instances that are
selected in Roblox Studio.
This service is particularly useful when developing Plugins, as
it allows the developer to access and manipulate the current selection.
Currently selected Instances can be obtained and set using
the Selection.Get and Selection.Set functions. The
Selection.SelectionChanged event fires whenever the current selection
changes.
For more information on using Selection and Plugins,
see Plugin.
Selection is also often used in the command bar, to set hidden properties or
run functions for selected Instances.
Note this class only applies to Roblox Studio and has no applicability to games.
Properties 1
SelectionThickness
: floatReadOnlyNotReplicatedThe thickness of the selection highlight outline drawn around selectedInstancesin Roblox Studio's viewport.The thickness of the selection highlight outline drawn around selected
Instancesin Roblox Studio's viewport.This read-only property returns the current outline thickness as a float. The default value is
0.02. The value is controlled by Roblox Studio and cannot be changed through the scripting API.This property can be read in
Pluginsto query the current selection visualization setting, such as when drawing custom overlays that need to match the built-in selection appearance.
Methods 4
Add
(instancesToAdd: Instances) → ()PluginAdds the givenInstancesto the current selection in Roblox Studio.Adds the
Instancesin the given array to the current selection.Instancesthat are already selected remain selected.Calling this function fires the
Selection.SelectionChangedevent if any newInstancesare added to the selection.Note this function can only be used in
Pluginsor the command bar. For setting the selection to an entirely new set of instances, seeSelection.Set. For removing instances from the current selection, seeSelection.Remove.Get
() → InstancesPluginReturns an array of currently selectedInstancesin Roblox Studio.Returns an array of currently selected
Instancesin Roblox Studio.If no
Instancesare selected, the array returned will be empty. This function can be used in conjunction with theSelection.SelectionChangedevent to get the selection whenever it changes.Note, this function can only be used in
Pluginsor the command line.For changing the current selection, please see
Selection.Set.Remove
(instancesToRemove: Instances) → ()PluginRemoves the givenInstancesfrom the current selection in Roblox Studio.Removes the
Instancesin the given array from the current selection.Instancesthat are not currently selected are ignored.Calling this function fires the
Selection.SelectionChangedevent if anyInstancesare removed from the selection.Note this function can only be used in
Pluginsor the command bar. For adding instances to the current selection, seeSelection.Add. For replacing the selection entirely, seeSelection.Set.Set
(selection: Instances) → ()PluginSets the currently selected objects in Roblox Studio toInstancesin the given array.Sets the currently selected objects in Roblox Studio to
Instancesin the given array.Calling this function will cause the
Selection.SelectionChangedevent to fire, unless the new selection set is identical to the previous selection.Note this function overwrites the existing selection. However, using
Selection.GetanInstancecan be added to the existing selection like so:
Events 1
SelectionChanged
Selection.SelectionChanged:Connect(function())Fires when theInstancesselected in Roblox Studio changes.Fires when the
Instancesselected in Roblox Studio changes.Note this event does not give the new selection. Developers will need to use the
Selection.Getfunction to obtain the current selection.Although this event can be used outside of plugins and the command bar, it only applies to the selection in Roblox Studio and therefore has no functionality outside of Studio.
To change the selection use the
Selection.Setfunction.
Selection also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.