Roblox UtilitiesDevlHub Roblox Documentation

Class

Selection

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

The Selection service controls the Instances that are selected in Roblox Studio.

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#

SelectionThicknessfloatThe thickness of the selection highlight outline drawn around selected Instances in Roblox Studio's viewport.ReadSafeReadOnlyNotReplicated

SelectionThickness: float#

ReadOnlyNotReplicatedReadSafe

The thickness of the selection highlight outline drawn around selected Instances in 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 Plugins to query the current selection visualization setting, such as when drawing custom overlays that need to match the built-in selection appearance.

Methods 4#

AddAdds the given Instances to the current selection in Roblox Studio.PluginSecurity security
GetReturns an array of currently selected Instances in Roblox Studio.PluginSecurity security
RemoveRemoves the given Instances from the current selection in Roblox Studio.PluginSecurity security
SetSets the currently selected objects in Roblox Studio to Instances in the given array.PluginSecurity security

Add(instancesToAdd: Instances): ()#

PluginSecurity security

Adds the Instances in the given array to the current selection. Instances that are already selected remain selected.

Calling this function fires the Selection.SelectionChanged event if any new Instances are added to the selection.

Note this function can only be used in Plugins or the command bar. For setting the selection to an entirely new set of instances, see Selection:Set(). For removing instances from the current selection, see Selection:Remove().

NameTypeDefaultDescription
instancesToAddInstancesAn array of Instances to add to the current selection.
Returns
  • ()

Get(): Instances#

PluginSecurity security

Returns an array of currently selected Instances in Roblox Studio.

If no Instances are selected, the array returned will be empty. This function can be used in conjunction with the Selection.SelectionChanged event to get the selection whenever it changes.

Note, this function can only be used in Plugins or the command line.

For changing the current selection, please see Selection:Set().

Returns
  • Instances — An array of currently selected Instances.

Remove(instancesToRemove: Instances): ()#

PluginSecurity security

Removes the Instances in the given array from the current selection. Instances that are not currently selected are ignored.

Calling this function fires the Selection.SelectionChanged event if any Instances are removed from the selection.

Note this function can only be used in Plugins or the command bar. For adding instances to the current selection, see Selection:Add(). For replacing the selection entirely, see Selection:Set().

NameTypeDefaultDescription
instancesToRemoveInstancesAn array of Instances to remove from the current selection.
Returns
  • ()

Set(selection: Instances): ()#

PluginSecurity security

Sets the currently selected objects in Roblox Studio to Instances in the given array.

Calling this function will cause the Selection.SelectionChanged event to fire, unless the new selection set is identical to the previous selection.

Note this function overwrites the existing selection. However, using Selection:Get() an Instance can be added to the existing selection like so:

NameTypeDefaultDescription
selectionInstancesAn array of Instances to set the current selection to.
Returns
  • ()

Events 1#

SelectionChangedFires when the Instances selected in Roblox Studio changes.

SelectionChanged()#

Fires when the Instances selected in Roblox Studio changes.

Note this event does not give the new selection. Developers will need to use the Selection:Get() function 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:Set() function.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed