Reference API Roblox

Engine API

Website

Related

Reference API Roblox

Object

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

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.
Tags: [NotCreatable, NotReplicated]

Member index 6

HistoryMember
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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 Object.

History 9

Members 6

Changed

Parameters (1)
propertystring

This event fires immediately after an object property is changed and it works with most use cases (see limitations below). The new value of a changed property is not passed in as a parameter, so it must be accessed by using object[property]. For example:

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

If you are only interested in listening to the change of one specific property, consider using the GetPropertyChangedSignal() method instead.

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

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.

Additionally, this 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.

History 1

ClassName

TypeDefault
string

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:

for _, child in workspace:GetChildren() do
    if child.ClassName == "Part" then
        print("Found a Part")
        -- will find Parts in model, but NOT TrussParts, WedgeParts, etc
    end
end
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 1

Tags: [ReadOnly, NotReplicated]

GetPropertyChangedSignal

Parameters (1)
propertystring
Returns (1)
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.

History 1

IsA

Parameters (1)
classNamestring
Returns (1)
bool

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 Lua 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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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(game.Players.Player.Character, BrickColor.new("Bright blue"))

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

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

History 1

Tags: [CustomLuaState]

className

TypeDefault
string
This property is deprecated. It exists only for backward compatibility, and should not be used for new work. ClassName should be used instead.
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 1

Tags: [ReadOnly, NotReplicated, Deprecated]

isA

Parameters (1)
classNamestring
Returns (1)
bool
This function is deprecated. It exists only for backward compatibility, and should not be used for new work. IsA should be used instead.
This function has a custom internal state. It may behave in a non-standard way.

History 3

  • 650 Change Tags of isA from [CustomLuaState] to [Deprecated, CustomLuaState]
  • 650 Change PreferredDescriptor of isA from to IsA
  • 647 Add isA
Tags: [Deprecated, CustomLuaState]

Settings