Reference API Roblox

Engine API

Website

Related

Reference API Roblox

ReflectionService

This class is not replicated. Its interface does not cross the network boundary.
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, NotReplicated]

Member index 5

HistoryMember
698GetClass(className: string, filter: Dictionary = nil): Dictionary?
698GetClasses(filter: Dictionary = nil): Array
698GetPropertiesOfClass(className: string, filter: Dictionary = nil): Array
698GetPropertyNames(name: string): Array
698GetStyledPropertyNames(name: string): Array
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
670Sandboxed: bool
680UniqueId: 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
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: 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()
657StyledPropertiesChanged()
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)

Description

ReflectionService allows scripts to query the engine for details about its API, including required security permissions, functionality, and inheritance structure. You can use this service to dynamically inspect classes and their properties, which can be useful for debugging, tooling, or creating dynamic behaviors based on the engine's capabilities.

The following is an example script that inspects classes and their properties:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local ReflectionService = game:GetService("ReflectionService")

-- Create a SecurityCapabilities object with all capabilities
local allCapabilities = SecurityCapabilities.new(table.unpack(Enum.SecurityCapability:GetEnumItems()))

-- Get all classes accessible with all capabilities
local allClasses = ReflectionService:GetClasses({ Security = allCapabilities })
print("Total classes:", #allClasses)

-- Get a specific class
local partClass = ReflectionService:GetClass("Part")
if partClass then
	print("\nPart class:")
	print("  Name:", partClass.Name)
	print("  Superclass:", partClass.Superclass and tostring(partClass.Superclass) or "none")
end

-- Get the first 5 properties of a class
local properties = ReflectionService:GetPropertiesOfClass("Part", { Security = allCapabilities })
print("\nPart properties:", #properties)
for i = 1, math.min(5, #properties) do
	print("  -", properties[i].Name)
end

History 11

Members 5

GetClass

Parameters (2)Default
classNamestring
filterDictionarynil
Returns (1)
Dictionary?

Given a class name in the Roblox API, returns a ReflectedClass dictionary with information about the associated class's reflection state. If no such class name exists, returns nil.

If you pass in a ReflectionClassFilter dictionary, you can adjust the set of eligible classes and adjust the output behavior:

1
2
3
4
5
6
7
8
{
	-- The security context to use. Can be more expansive than the current script's security.
	Security: SecurityCapabilities?, -- default: SecurityCapabilities.fromCurrent()
	-- Require classes to derive from the passed-in class name.
	IsA: string?, -- default: nil
	-- Whether to exclude Studio display information about the class.
	ExcludeDisplay: boolean?, -- default: false
}

If the class name is valid, you'll get the following ReflectedClass dictionary as output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
	-- The name of the class.
	Name: string,
	-- The class's parent in the instance hierarchy (unless it's the root).
	Superclass: string?,
	-- The names of the class's direct children in the instance hierarchy.
	Subclasses: {string},
	-- Studio display information.
	Display: {
		-- Always "General" for classes.
		Category: string,
		-- A message indicating that the class is deprecated, if applicable.
		DeprecationMessage: string?,
	}?,
	-- The security permissions required to access this class.
	Permits: {
		-- If the class is a Service, the security capabilities required to obtain access. If not applicable, this field isn't present.
		GetService: SecurityCapabilities?,
		-- The security capabilities required to create an instance of this class. If not possible, this field isn't present.
		New: SecurityCapabilities?,
	}
}
This function has a custom internal state. It may behave in a non-standard way.

History 2

Tags: [CustomLuaState]

GetClasses

Parameters (1)Default
filterDictionarynil
Returns (1)
Array

Returns a list of ReflectedClass dictionaries for all classes in the Roblox API that match the provided filter criteria.

If you pass in a ReflectionClassFilter dictionary, you can adjust the set of eligible classes and adjust the output behavior:

1
2
3
4
5
6
7
8
{
	-- The security context to use. Can be more expansive than the current script's security.
	Security: SecurityCapabilities?, -- default: SecurityCapabilities.fromCurrent()
	-- Require classes to derive from the passed-in class name.
	IsA: string?, -- default: nil
	-- Whether to exclude Studio display information about the classes.
	ExcludeDisplay: boolean?, -- default: false
}

You'll get a list of ReflectedClass dictionaries as output, each with the same structure as described in the GetClass method. If there are no classes that match the filter criteria, you'll receive an empty list.

This function has a custom internal state. It may behave in a non-standard way.

History 2

Tags: [CustomLuaState]

GetPropertiesOfClass

Parameters (2)Default
classNamestring
filterDictionarynil
Returns (1)
Array

Given a class name in the Roblox API, returns a list of ReflectedProperty dictionaries for all properties of that class that match the provided filter criteria. If no such class name exists, returns nil.

If you pass in a ReflectionMemberFilter dictionary, you can adjust the set of eligible properties and adjust the output behavior:

1
2
3
4
5
6
7
8
{
	-- The security context to use. Can be more expansive than the current script's security.
	Security: SecurityCapabilities?, -- default: SecurityCapabilities.fromCurrent()
	-- Whether to exclude inherited properties from superclasses.
	ExcludeInherited: boolean?, -- default: false
	-- Whether to exclude Studio display information about the properties.
	ExcludeDisplay: boolean?, -- default: false
}

If the class name is valid and that class has properties, you'll get a list of ReflectedProperty dictionaries as output, each with the following structure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
	-- The name of the property.
	Name: string,
	-- Whether the property is serialized (able to be saved to disk or sent over the network).
	Serialized: boolean,
	-- The type of the property.
	Type: ReflectionType,
	-- The content type of the property, if applicable.
	ContentType: Enum.AssetType?,
	-- Studio display information.
	Display: {
		-- The category under which the property is listed in Studio.
		Category: string,
		-- A message indicating that the property is deprecated, if applicable.
		DepreciationMessage: string?,
		-- The order in which the property appears in Studio.
		LayoutOrder: number,
	}?,
	-- The security permissions required to access this property.
	Permits: {
		-- The security context required to read this property.
		Read: SecurityCapabilities?,
		-- The security context required to read this property while thread-safe.
		ReadParallel: SecurityCapabilities?,
		-- The security context required to write to this property.
		Write: SecurityCapabilities?,
		-- The security context required to write to this property while thread-safe.
		WriteParallel: SecurityCapabilities?,
	},
}
This function has a custom internal state. It may behave in a non-standard way.

History 2

Tags: [CustomLuaState]

GetPropertyNames

Parameters (1)
namestring
Returns (1)
Array
This function has a custom internal state. It may behave in a non-standard way.

History 2

Tags: [CustomLuaState]

GetStyledPropertyNames

Parameters (1)
namestring
Returns (1)
Array
This function has a custom internal state. It may behave in a non-standard way.

History 2

Tags: [CustomLuaState]

Settings