Roblox UtilitiesDevlHub Roblox Documentation

Class

Object

NotCreatableNotReplicated
Memory category
Instances
Subclasses
10

Object is the base class for all classes in the Roblox class hierarchy.

Object is the base class for all classes in the Roblox class hierarchy. Every other class that the Roblox Engine defines inherits all of the members of Object. It is not possible to directly create an Object.

Properties 2#

ClassNamestringA read-only string representing the class this Object belongs to.ReadSafeReadOnlyNotReplicated
classNamestringReadSafeDeprecatedReadOnlyNotReplicated

ClassName: string#

ReadOnlyNotReplicatedReadSafe

A read-only string representing the class this Object belongs to.

This property can be used with various other functions that are used to identify objects by type, such as Object:IsA() or Instance:FindFirstChildOfClass().

Note this property is read only and cannot be altered by scripts. Developers wishing to change an object's class will instead have to create a new Object.

Unlike Object:IsA(), ClassName can be used to check if an object belongs to a specific class ignoring class inheritance. For example:

className: string#

ReadOnlyNotReplicatedDeprecatedReadSafeDeprecated

Deprecated. This deprecated property is a variant of Object.ClassName which should be used instead.

Methods 3#

GetPropertyChangedSignalGet an event that fires when a given property of the object changes.
IsAReturns true if an object's class matches or inherits from a given class.SafeCustomLuaState
isADeprecatedCustomLuaState

GetPropertyChangedSignal(property: string): RBXScriptSignal#

This method returns an event that behaves exactly like the Changed event, except that it only fires when the given property changes. It's generally a good idea to use this method instead of a connection to Changed with a function that checks the property name. Subsequent calls to this method on the same object with the same property name return the same event.

ValueBase objects, such as IntValue and StringValue, use a modified Changed event that fires with the contents of their Value property. As such, this method provides a way to detect changes in other properties of those objects.

Note that this event will not pass any arguments to a connected function, so the value of the changed property must be read directly within a script.

Limitations#

The event returned by this method does not fire for physics-related changes, such as when the CFrame, AssemblyLinearVelocity, AssemblyAngularVelocity, Position, or Orientation properties of a BasePart change due to gravity. To detect changes in these properties, consider using a physics-based event like RunService.PreSimulation.

Additionally, the returned event may not fire on every modification of properties that change very frequently, and/or it may not fire for such properties at all. It's recommended that you carefully test for property changes that impact game logic.

NameTypeDefaultDescription
propertystringThe property to connect to.
Returns

IsA(className: string): boolean#

CustomLuaStateSafe

IsA returns true if the object's class is equivalent to or a subclass of a given class. This function is similar to the instanceof operators in other languages, and is a form of type introspection. To ignore class inheritance, test the ClassName property directly instead. For checking native Luau data types (number, string, etc) use the functions type and typeof.

Most commonly, this function is used to test if an object is some kind of part, such as Part or WedgePart, which inherits from BasePart (an abstract class). For example, if your goal is to change all of a character's limbs to the same color, you might use GetChildren to iterate over the children, then use IsA to filter non-BasePart objects which lack the BrickColor property:

Luau
local Players = game:GetService("Players")

local function paintFigure(character, color)
	-- Iterate over the child objects of the character
	for _, child in character:GetChildren() do
		-- Filter out non-part objects, such as Shirt, Pants and Humanoid
		-- R15 use MeshPart and R6 use Part, so we use BasePart here to detect both:
		if child:IsA("BasePart") then
			child.BrickColor = color
		end
	end
end
paintFigure(Players.Player.Character, BrickColor.new("Bright blue"))

Since all classes inherit from Object, calling object:IsA("Object") will always return true.

NameTypeDefaultDescription
classNamestringThe class against which the Object's class will be checked. Case-sensitive.
Returns
  • boolean — Describes whether the Object's class matched or is a subclass of the given class.

isA(className: string): boolean#

DeprecatedCustomLuaStateDeprecated

Deprecated. This deprecated function is a variant of Object:IsA() which should be used instead.

NameTypeDefaultDescription
classNamestring
Returns
  • boolean

Events 1#

ChangedFires immediately after a property of the object changes, with some limitations.

Changed(property: string)#

This event fires immediately after an object property is changed, with some exceptions (see below). The new value of a changed property is not passed as a parameter. Instead, you can access it using object[property]:

Code
object.Changed:Connect(function(property)
	print("The new property's value is", object[property])
end)

For ValueBase objects such as IntValue and StringValue, this event only fires when the object's Value property changes. To detect other changes in ValueBase objects, use GetPropertyChangedSignal().

Limitations#

This event does not fire for physics-related changes, such as when the CFrame, AssemblyLinearVelocity, AssemblyAngularVelocity, Position, or Orientation properties of a BasePart change due to gravity. To detect changes in these properties, consider using a physics-based event like RunService.PreSimulation. Similarly, the Changed event does not fire when AssemblyMass updates due to a change in material, size, or density for a welded part (but the event does fire for Mass if you modify a part's size).

For properties that change frequently, the Changed event might not fire for every modification, or it might not fire at all. If a property change impacts your game logic, test carefully to ensure the event is firing as you expect.

NameTypeDefaultDescription
propertystringThe name of the property that changed.

Subclasses 10#