Skip to content

Object


Summary

Constructors

create (className: string, properties: array) : Instance

Methods

GetChildrenOfClass (parent: Instance, className: string) : Instances
GetChildrenWhichAre (parent: Instance, className: string) : Instances
GetDescendantsOfClass (parent: Instance, className: string) : Instances Deprecated
GetDescendantsWhichAre (parent: Instance, className: string) : Instances
ClearChildrenOfClass (parent: Instance, className: string)
ClearChildrenWhichAre (parent: Instance, className: string)
AddTag (instance: Instance, tag: string) Deprecated
RemoveTag (instance: Instance, tag: string) Deprecated
HasTag (instance: Instance, tag: string) : boolean Deprecated
WaitForPropertyValueChanged (instance: Instance, propertyName: string) : Variant

Constructors

create

Meant to replace Roblox's built in Instance.new method, this contructor provides a more robust way to create instances. The properties argument is an array that contains sub-arrays formatted as such: { "PropertyName", Value }; however, there are some unique property flags that can be used to create large Instance trees with ease. Properties are applied in the order they are provided.

Object.create ( className: string, properties: array ) : Instance

Parameters

className : string
properties : array

Returns

Instance
local Object = Utility.Object

Object.create("Part", {
    { "Name", "NewPart" },
    { "Size", Vector3.new(1, 1, 1) },
    { "Position", Vector3.new(0, 15, 0) },
    { "Anchored", true },
    { "Parent", workspace }
})

__Children is a special property flag that allows you to create a tree of Instance objects. The value of __Children should be an array of Instance objects or arrays that contain a ClassName and properties to be used to construct a new Instance. The Instance objects are created in the order they are provided. Every Instance object created in the __Children array will be parented to the Instance object that __Children is a property of.

The entire Instance tree will be finished before the absolute parent Instance is returned.

local Object = Utility.Object

Object.create("Model", {
    { "Name", "NewModel" },
    { "__Children", {
        Object.create("Part", {
            { "Name", "BottomPart" },
            { "Size", Vector3.new(1, 1, 1) },
            { "Position", Vector3.new(0, 10, 0) },
            { "BrickColor", BrickColor.new("Bright blue") },
            { "Anchored", true }
        }),
        Object.create("Part", {
            { "Name", "TopPart" },
            { "Size", Vector3.new(1, 1, 1) },
            { "Position", Vector3.new(0, 15, 0) },
            { "BrickColor", BrickColor.new("Bright red") },
            { "Anchored", true }
        })
    } },
    { "Parent", workspace }
})
.
└── Workspace/
    └── Model "NewModel"/
        ├── Part "BottomPart"
        └── Part "TopPart"
local Object = Utility.Object

local bottomPart: Part = Object.create("Part", {
    { "Name", "BottomPart" },
    { "Size", Vector3.new(1, 1, 1) },
    { "Position", Vector3.new(0, 10, 0) },
    { "BrickColor", BrickColor.new("Bright blue") },
    { "Anchored", true }
})

Object.create("Model", {
    { "Name", "NewModel" },
    { "__Children", {
        bottomPart,
        Object.create("Part", {
            { "Name", "MiddlePart" },
            { "Size", Vector3.new(1, 1, 1) },
            { "Position", Vector3.new(0, 12.5, 0) },
            { "BrickColor", BrickColor.new("Bright yellow") },
            { "Anchored", true },
            { "__Children", {
                Object.Create("PointLight", {
                    { "Name", "Light" },
                    { "Range", 10 },
                    { "Color", Color3.fromRGB(255, 255, 0) },
                    { "Brightness", 2 }
                })
            } }
        }),
        { "Part", {
            { "Name", "TopPart" },
            { "Size", Vector3.new(1, 1, 1) },
            { "Position", Vector3.new(0, 15, 0) },
            { "BrickColor", BrickColor.new("Bright red") },
            { "Anchored", true }
        } }
    } },
    { "Parent", workspace }
})
.
└── Workspace/
    └── Model "NewModel"/
        ├── Part "BottomPart"
        ├── Part "MiddlePart"/
           └── PointLight "Light"
        └── Part "TopPart"

Methods

GetChildrenOfClass

Returns an array of Instance children that have the specific ClassName. It does not check for class inheritance. Use GetChildrenWhichAre to respect class inheritance.

Object:GetChildrenOfClass ( parent: Instance, className: string ) : Instances

Parameters

parent : Instance
className : string

Returns

Instances
local Object = Utility.Object

local parts: { Part } = Object:GetChildrenOfClass(workspace, "Part")

GetChildrenWhichAre

Returns an array of Instance children that are of the specific ClassName or inherit from it. Uses IsA to check for class inheritance.

Object:GetChildrenWhichAre ( parent: Instance, className: string ) : Instances

Parameters

parent : Instance
className : string

Returns

Instances
local Object = Utility.Object

local baseParts: { BasePart } = Object:GetChildrenWhichAre(workspace, "BasePart")

GetDescendantsOfClass

Deprecated

Use Instance:QueryDescendants() instead. Returns an array of Instance descendants that have the specific ClassName. It does not check for class inheritance.

Object:GetDescendantsOfClass ( parent: Instance, className: string ) : Instances

Parameters

parent : Instance
className : string

Returns

Instances

GetDescendantsWhichAre

Returns an array of Instance descendants that are of the specific ClassName or inherit from it. Uses IsA to check for class inheritance.

Object:GetDescendantsWhichAre ( parent: Instance, className: string ) : Instances

Parameters

parent : Instance
className : string

Returns

Instances

ClearChildrenOfClass

Destroys all Instance children that have the specific ClassName. It does not check for class inheritance. Use ClearChildrenWhichAre to respect class inheritance.

Object:ClearChildrenOfClass ( parent: Instance, className: string ) : ()

Parameters

parent : Instance
className : string
local Object = Utility.Object

Object:ClearChildrenOfClass(workspace, "Part")

ClearChildrenWhichAre

Destroys all Instance children that are of the specific ClassName or inherit from it. Uses IsA to check for class inheritance.

Object:ClearChildrenWhichAre ( parent: Instance, className: string ) : ()

Parameters

parent : Instance
className : string
local Object = Utility.Object

Object:ClearChildrenWhichAre(workspace, "BasePart")

AddTag

Deprecated

Adds the specified CollectionService tag to the given instance.

Object:AddTag ( instance: Instance, tag: string ) : ()

Parameters

instance : Instance
tag : string

RemoveTag

Deprecated

Removes the specified CollectionService tag from the given instance.

Object:RemoveTag ( instance: Instance, tag: string ) : ()

Parameters

instance : Instance
tag : string

HasTag

Deprecated

Returns whether or not the given instance has the specified CollectionService tag.

Object:HasTag ( instance: Instance, tag: string ) : boolean

Parameters

instance : Instance
tag : string

Returns

boolean

WaitForPropertyValueChanged

Can Yield

Yields the current thread until the specified property of the given instance changes value. Returns the new value of the property.

Object:WaitForPropertyValueChanged ( instance: Instance, propertyName: string ) : Variant

Parameters

instance : Instance
propertyName : string

Returns

Variant
local Object = Utility.Object

local part = workspace:WaitForChild("Part")

print("Current Transparency:", part.Transparency)

local newTransparency = Object:WaitForPropertyValueChanged(part, "Transparency")

print("New Transparency:", newTransparency)