Class
Object
Object is the base class for all classes in the Roblox class hierarchy.
About Object
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 1
ClassName
: stringReadOnlyNotReplicatedA read-only string representing the class thisObjectbelongs to.A read-only string representing the class this
Objectbelongs to.This property can be used with various other functions that are used to identify objects by type, such as
Object.IsAorInstance.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:
Methods 2
GetPropertyChangedSignal
(property: string) → RBXScriptSignalGet an event that fires when a given property of the object changes.This method returns an event that behaves exactly like the
Changedevent, except that it only fires when the given property changes. It's generally a good idea to use this method instead of a connection toChangedwith 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.ValueBaseobjects, such asIntValueandStringValue, use a modifiedChangedevent that fires with the contents of theirValueproperty. 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, orOrientationproperties of aBasePartchange due to gravity. To detect changes in these properties, consider using a physics-based event likeRunService.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.
IsA
(className: string) → booleanReturns true if an object's class matches or inherits from a given class.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
ClassNameproperty directly instead. For checking native Luau data types (number, string, etc) use the functionstypeandtypeof.Most commonly, this function is used to test if an object is some kind of part, such as
PartorWedgePart, which inherits fromBasePart(an abstract class). For example, if your goal is to change all of a character's limbs to the same color, you might useGetChildrento iterate over the children, then use IsA to filter non-BasePartobjects which lack theBrickColorproperty: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, callingobject:IsA("Object")will always return true.
Events 1
Changed
Object.Changed:Connect(function(property))Fires immediately after a property of the object changes, with some limitations.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]:object.Changed:Connect(function(property) print("The new property's value is", object[property]) end)- If you are only interested in listening for changes to one specific
property, consider using the
GetPropertyChangedSignal()method instead. - To listen for changes in attributes, see
Instance.GetAttributeChangedSignalandInstance.AttributeChanged. - To detect when children are added or removed, see
Instance.ChildAddedandInstance.ChildRemoved.
For
ValueBaseobjects such asIntValueandStringValue, this event only fires when the object'sValueproperty changes. To detect other changes inValueBaseobjects, useGetPropertyChangedSignal().Limitations
This event does not fire for physics-related changes, such as when the
CFrame,AssemblyLinearVelocity,AssemblyAngularVelocity,Position, orOrientationproperties of aBasePartchange due to gravity. To detect changes in these properties, consider using a physics-based event likeRunService.PreSimulation. Similarly, theChangedevent does not fire whenAssemblyMassupdates due to a change in material, size, or density for a welded part (but the event does fire forMassif you modify a part's size).For properties that change frequently, the
Changedevent 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.- If you are only interested in listening for changes to one specific
property, consider using the
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.