Reference API Roblox

Engine API

Website

Related

Reference API Roblox

Selection

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

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 14

HistoryMember
553SelectionThickness: float
648Add(instancesToAdd: Instances): null
620AddFocusCallback(priority: int, function: Function): RBXScriptConnection
573ClearTerrainSelectionHack(): null
648Get(): Instances
648Remove(instancesToRemove: Instances): null
648Set(selection: Instances): null
573SetTerrainSelectionHack(center: Vector3, size: Vector3): null
462SelectionChanged()
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 2

HistoryMember

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

Members 14

Add

Parameters (1)
instancesToAddInstances
Returns (1)
null

History 4

AddFocusCallback

Parameters (2)
priorityint
functionFunction
Returns (1)
RBXScriptConnection

History 1

ClearTerrainSelectionHack

Parameters (0)
No parameters.
Returns (1)
null

History 2

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().

History 5

  • 648 Change ReturnType of Get from Objects to Instances
  • 462 Change ThreadSafety of Get from to Unsafe
  • 151 Change Security of Get from security1 to PluginSecurity
  • 150 Change Security of Get from LocalUserSecurity to security1
  • 47 Add Get

Remove

Parameters (1)
instancesToRemoveInstances
Returns (1)
null

History 4

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.

History 2

SelectionThickness

TypeDefault
float
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 2

Tags: [ReadOnly, NotReplicated]

Set

Parameters (1)
selectionInstances
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)

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)
centerVector3
sizeVector3
Returns (1)
null

History 2

Removed members 2

Settings