Selection
The Selection service controls the Instances that are selected in Roblox Studio.
Memory category | Instances |
---|
Member index 14
Removed member index 2
History | Member |
---|
Description
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.
History 45
- 648 Change Parameters of Set from (selection: Objects) to (selection: Instances)
- 648 Change Parameters of Remove from (instancesToRemove: Objects) to (instancesToRemove: Instances)
- 648 Change ReturnType of Get from Objects to Instances
- 648 Change Parameters of Add from (instancesToAdd: Objects) to (instancesToAdd: Instances)
- 620 Add AddFocusCallback
- 583 Remove
- 578 Remove
- 578 Add
- 578 Add
- 574 Add
- 573 Change ReturnType of SetTerrainSelectionHack from void to null
- 573 Change ReturnType of Set from void to null
- 573 Change ReturnType of Remove from void to null
- 573 Change ReturnType of ClearTerrainSelectionHack from void to null
- 573 Change ReturnType of Add from void to null
- 567 Change WriteSecurity of from None to RobloxScriptSecurity
- 567 Change ReadSecurity of from None to RobloxScriptSecurity
- 567 Add
- 566 Add
- 553 Change Default of SelectionThickness from to
- 553 Change Default of from to
- 553 Change Default of from to
- 547 Add
- 493 Add SetTerrainSelectionHack
- 493 Add ClearTerrainSelectionHack
- 488 Add SelectionThickness
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 469 Change Tags of from [ReadOnly, NotReplicated] to [Hidden, ReadOnly, NotReplicated]
- 462 Change ThreadSafety of SelectionChanged from to Unsafe
- 462 Change ThreadSafety of Set from to Unsafe
- 462 Change ThreadSafety of Remove from to Unsafe
- 462 Change ThreadSafety of Get from to Unsafe
- 462 Change ThreadSafety of Add from to Unsafe
- 462 Change ThreadSafety of from to ReadOnly
- 449 Add Remove
- 449 Add Add
- 438 Add
- 151 Change Security of Set from security1 to PluginSecurity
- 151 Change Security of Get from security1 to PluginSecurity
- 150 Change Security of Set from LocalUserSecurity to security1
- 150 Change Security of Get from LocalUserSecurity to security1
- 47 Add SelectionChanged
- 47 Add Set
- 47 Add Get
- 47 Add Selection
Members 14
Add
Parameters (1) | ||
---|---|---|
instancesToAdd | Instances | |
Returns (1) | ||
null |
Security | PluginSecurity |
---|---|
Thread safety | Unsafe |
AddFocusCallback
Parameters (2) | ||
---|---|---|
priority | int | |
function | Function | |
Returns (1) | ||
RBXScriptConnection |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 1
- 620 Add AddFocusCallback
ClearTerrainSelectionHack
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
- 573 Change ReturnType of ClearTerrainSelectionHack from void to null
- 493 Add ClearTerrainSelectionHack
Get
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Instances |
Returns an array of currently selected Instances in Roblox Studio.
If no Instances are selected, the array returned 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().
Security | PluginSecurity |
---|---|
Thread safety | Unsafe |
Remove
Parameters (1) | ||
---|---|---|
instancesToRemove | Instances | |
Returns (1) | ||
null |
Security | PluginSecurity |
---|---|
Thread safety | Unsafe |
SelectionChanged
Parameters (0) | ||
---|---|---|
No parameters. |
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.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of SelectionChanged from to Unsafe
- 47 Add SelectionChanged
SelectionThickness
Type | Default | |
---|---|---|
float |
Thread safety | ReadSafe |
---|---|
Category | Appearance |
Loaded/Saved | false |
History 2
- 553 Change Default of SelectionThickness from to
- 488 Add SelectionThickness
Set
Parameters (1) | ||
---|---|---|
selection | Instances | |
Returns (1) | ||
null |
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:
local selected = Selection:Get()
table.insert(selected, object)
Selection:Set(selected)
Security | PluginSecurity |
---|---|
Thread safety | Unsafe |
History 6
- 648 Change Parameters of Set from (selection: Objects) to (selection: Instances)
- 573 Change ReturnType of Set from void to null
- 462 Change ThreadSafety of Set from to Unsafe
- 151 Change Security of Set from security1 to PluginSecurity
- 150 Change Security of Set from LocalUserSecurity to security1
- 47 Add Set
SetTerrainSelectionHack
Parameters (2) | ||
---|---|---|
center | Vector3 | |
size | Vector3 | |
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
- 573 Change ReturnType of SetTerrainSelectionHack from void to null
- 493 Add SetTerrainSelectionHack