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
573Add(instancesToAdd: Objects): null
620AddFocusCallback(priority: int, function: Function): RBXScriptConnection
573ClearTerrainSelectionHack(): null
462Get(): Objects
573Remove(instancesToRemove: Objects): null
573Set(selection: Objects): null
573SetTerrainSelectionHack(center: Vector3, size: Vector3): null
462SelectionChanged()
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553ClassName: string
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
553className: string
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
486GetChildren(): Objects
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
462GetPropertyChangedSignal(property: string): RBXScriptSignal
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsA(className: 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
553children(): Objects
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
553getChildren(): Objects
462isA(className: string): bool
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462Changed(property: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)

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 41

Members 14

Add

Parameters (1)
instancesToAddObjects
Returns (1)
null

History 3

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)
Objects

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 4

  • 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)
instancesToRemoveObjects
Returns (1)
null

History 3

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)
selectionObjects
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 5

  • 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