Creator Guide
English
English
  • 🚩Introduction to OVERDARE
  • 🐤Get Started
    • OVERDARE App
    • OVERDARE Studio
  • 📌Policy
    • Community Guidelines
    • UGC Creation Guidelines
    • Guidelines on the External Use of UGC
    • Logo Usage Guidelines
    • Intellectual Property Rights Policy
    • Reporting Guidelines
    • Guidelines on Disputing Suspensions and Bans
    • Creator Payout Policy
    • Monetization Guidelines
  • 🏰Studio Manual
    • Studio Interface
    • Asset Import
    • Coordinate System
    • Game Settings
    • Studio Test Play
    • World Publish
    • Collaboration
    • Script Editor
    • Align Tool
    • Animation Editor
    • Material Manager
    • Collision Groups
    • Tag Editor
    • Payout Guideline
    • Object
      • Part
      • Model
      • Character
        • Humanoid Description
      • Camera
      • Physics
      • Lighting
      • Tool
      • VFX
      • Sound
      • GUI
  • 📝Script Manual
    • Script Overview
    • Basic Guide to Lua
    • Coding Style
    • Object Reference
    • Event
    • Server-Client Communication
    • BindableEvent
    • Value Objects
    • Mobile Input Handling
    • Tween
    • Breakpoint
    • Module Script
    • TPS Strafing System
    • Saving & Loading Data
    • Unity Developer Guide
  • 📚API Reference
    • Enums
      • ActuatorRelativeTo
      • AnimationPriority
      • AspectType
      • AssetTypeVerification
      • BorderMode
      • CameraMode
      • CameraType
      • ContextActionResult
      • CoreGuiType
      • DominantAxis
      • EasingDirection
      • EasingStyle
      • ForceLimitMode
      • HttpCompression
      • HttpContentType
      • HumanoidDisplayDistanceType
      • HumanoidStateType
      • KeyCode
      • Material
      • MaterialPattern
      • NormalId
      • ParticleEmitterShape
      • ParticleEmitterShapeInOut
      • ParticleEmitterShapeStyle
      • ParticleFlipbookLayout
      • ParticleFlipbookMode
      • ParticleOrientation
      • PartType
      • PlaybackState
      • RaycastFilterType
      • RollOffMode
      • RotationType
      • UserInputState
      • UserInputType
      • VelocityConstraintMode
    • DataTypes
      • BlendSpaceSampleSata
      • BrickColor
      • CFrame
      • Color3
      • ColorSequence
      • ColorSequenceKeypoint
      • Content
      • Enum
      • EnumItem
      • NumberRange
      • NumberSequence
      • NumberSequenceKeypoint
      • OverlapParams
      • PhysicalProperties
      • Ray
      • RaycastParams
      • RaycastResult
      • ScriptConnection
      • ScriptSignal
      • TweenInfo
      • Udim
      • Udim2
      • Vector2
      • Vector3
    • Classes
      • Animation
      • AngularVelocity
      • AnimationTrack
      • Animator
      • Atmosphere
      • Attachment
      • Backpack
      • BackpackItem
      • BasePart
      • BaseScript
      • Beam
      • BindableEvent
      • BlendSpace
      • BoolValue
      • Bone
      • Camera
      • CharacterMesh
      • CollectionService
      • Constraint
      • ContextActionService
      • CoreGui
      • DataStore
      • DataModel
      • DataStoreGetOptions
      • DataStoreIncrementOptions
      • DataStoreInfo
      • DataStoreKeyPages
      • DataStoreKeyInfo
      • DataStoreService
      • DataStoreListingPages
      • DataStoreSetOptions
      • FormFactorPart
      • Frame
      • Folder
      • GlobalDataStore
      • GuiBase2d
      • GuiButton
      • GuiObject
      • HttpService
      • Humanoid
      • HumanoidDescription
      • ImageButton
      • ImageLabel
      • InputObject
      • IntValue
      • LayerCollector
      • Instance
      • Light
      • Lighting
      • LinearVelocity
      • LocalScript
      • LuaSourceContainer
      • MaterialService
      • MaterialVariant
      • MeshPart
      • Model
      • ModuleScript
      • Mouse
      • OrderedDataStore
      • Pages
      • Part
      • ParticleEmitter
      • PhysicsService
      • Player
      • PlayerGui
      • Players
      • PlayerScripts
      • PointLight
      • PVInstance
      • ReplicatedStorage
      • RemoteEvent
      • ScreenGui
      • RunService
      • Script
      • ServerStorage
      • ServiceProvider
      • Skeleton
      • ServerScriptService
      • Sound
      • SoundService
      • SoundGroup
      • SpotLight
      • SpawnLocation
      • StarterCharacterScripts
      • StarterPack
      • StarterGui
      • StarterPlayer
      • StarterPlayerScripts
      • StringValue
      • SurfaceGui
      • SurfaceGuiBase
      • Team
      • Teams
      • TextLabel
      • TextButton
      • Tool
      • Trail
      • Tween
      • TweenService
      • TweenBase
      • UIAspectRatioConstraint
      • UserGameSettings
      • UserInputService
      • UserSettings
      • VectorForce
      • Workspace
      • WrapLayer
      • WorldRoot
      • WrapTarget
  • 🅰️OVERDARE Glossary
  • 📰Release Note
Powered by GitBook
On this page
  • Overview
  • Description
  • Properties
  • Parent
  • Archivable
  • ClassName
  • Name
  • Methods
  • Clone
  • Destroy
  • FindFirstAncestor
  • FindFirstAncestorOfClass
  • FindFirstAncestorWhichIsA
  • FindFirstChild
  • FindFirstChildOfClass
  • GetAttribute
  • GetAttributes
  • GetChildren
  • GetDescendants
  • IsDescendantOf
  • IsA
  • SetAttribute
  • WaitForChild
  • AddTag
  • RemoveTag
  • HasTag
  • GetTags
  • Events
  • AncestryChanged
  • AttributeChanged
  • Changed
  • ChildAdded
  • ChildRemoved
  • DescendantAdded
  • DescendantRemoving
  • Destroying
  1. API Reference
  2. Classes

Instance

Instance : InstanceBase

Overview

Instance is the top parent class of all OVERDARE Lua classes.

Description

An instance is an abstract class that represents the elements composing a data model tree. It enables the storage and modification of parent and child relationships within a tree structure, as well as provides the properties necessary to access and differentiate instances. Instances allow for creation, destruction, and replication, and include features that facilitate locating or modifying instances deployed in the world. These features enable comparisons and modifications based on attributes such as tag, class names, instance names, and more.

Properties

Parent

Instance

The parent instance of that instance in the data model tree.

Code Samples

print(Part.Parent)

Archivable

bool

"Archivable" property is to determine whether an instance can be saved, restored, and preserved across gameplay sessions.

Code Samples

ClassName

string

Represents the Lua Class name of that instance.

Code Samples

local Part = script.Parent
print(Part.ClassName)

Name

string

Represents the name of that instance. The Name property is a user-defined string that identifies the instance within the hierarchy. It can be used to reference and differentiate instances programmatically.

Code Samples

local Part = script.Parent

Part.Name = "NewPart"

Methods

Clone

This method creates a copy of the instance and its descendants (if any) in the data model tree. The cloned instance will be a separate entity and not linked to the original, but it retains the same properties, attributes, and child instances as the original at the time of cloning.

Parameters

Return

Instance

Code Samples

local Workspace = game:GetService("Workspace")
local Part = Workspace.Part

local NewPart = Part:Clone(Part)
NewPart.Position = Part.Position + Vector3.new(300, 0, 0)
NewPart.Parent = Workspace

Destroy

This method deletes (destroys) the instance from the data model tree. The LuaDestroy method removes the instance and its descendants (if any) from the hierarchy permanently. Note: Once an instance is destroyed, it cannot be recovered.

Parameters

Return

virtual void

Code Samples

local Workspace = game:GetService("Workspace")
local Part = Workspace.Part

Part:Destroy()

FindFirstAncestor

An instance method used to find the first ancestor in the hierarchy by matching its name with the specified InName parameter. This allows developers to traverse up the hierarchy to locate an instance with a specific name.

If no matching ancestor is found, the method returns nil.

Parameters

string InName

Return

Instance

Code Samples

local Part = script.Parent

local Ancestor = Part:FindFirstAncestor("ParentPart")
print(Ancestor)

FindFirstAncestorOfClass

Finds the first ancestor of the instance that matches the specified class name InClassName. This method is useful for traversing up the object hierarchy to locate a specific class type.

Parameters

string InClassName

The first ancestor that matches the specified class name, or nil if no match is found.

Return

Instance

Code Samples

local Part = script.Parent

--wait(1)
local AncestorOfClass = Part:FindFirstAncestorOfClass("Part")
print(AncestorOfClass)

FindFirstAncestorWhichIsA

Checks if the current instance is a descendant of another instance.

Parameters

string InClassName

The class name to check against

Return

Instance

Code Samples

local Part = script.Parent

local AncestorWhichIsA = Part:FindFirstAncestorWhichIsA("Instance")
print(AncestorWhichIsA)

FindFirstChild

Finds the first child of the instance that matches the given name InName. If the recursive parameter is set to true, the method searches through all descendants of the instance. If no matching child is found, the method returns nil.

Parameters

string InName

bool recursive

Return

Instance

Code Samples

local Workspace = game:GetService("Workspace")

local Part = Workspace:FindFirstChild("Part")
print(Part)

FindFirstChildOfClass

This method retrieves the first child of a given instance that matches the specified class name. If the bRecursive parameter is set to true, the method searches all descendants of the instance to find a matching child. Returns the child instance if found; otherwise, it returns nil.

Parameters

string InClassName

bool bRecursive

Return

Instance

Code Samples

local Workspace = game:GetService("Workspace")

local Part = Workspace:FindFirstChildOfClass("Part")
print(Part)

GetAttribute

Query the value of an attribute with a specific name.

Parameters

string attribute

Return

Value

Code Samples

local AttributeName = "Number"
local SetValue = 1
Part:SetAttribute(AttributeName, SetValue)

local GetValue = Part:GetAttribute(AttributeName)
print(GetValue)

GetAttributes

Returns all attributes.

Parameters

Return

Value

Code Samples

Part:SetAttribute("Number", 1)
Part:SetAttribute("Text", "Hello")

local AttributeList = Part:GetAttributes()
for attributeName, attributeValue in pairs(AttributeList) do
    print(attributeName, " : ", attributeValue)
end

GetChildren

The GetChildren method retrieves an array containing all direct children of the instance. This is useful for accessing immediate child objects without including descendants beyond the top level.

Parameters

Return

array

Code Samples

local Workspace = game:GetService("Workspace")

local Children = Workspace:GetChildren() 
for _, child in ipairs(Children) do
    print(child.Name)
end

GetDescendants

The GetDescendants method retrieves an array containing all descendant objects of the instance, including both direct children and nested descendants at all levels.

Parameters

Return

array

Code Samples

local Workspace = game:GetService("Workspace")

local Descendants = Workspace:GetDescendants()
for _, descendant in ipairs(Descendants) do
    print(descendant.Name)
end

IsDescendantOf

The IsDescendantOf method checks if the current instance is a descendant of the specified ancestor instance.

Parameters

Instance InAncestor

Return

bool

Code Samples

local Part = script.Parent
local IsDescendantOf = script:IsDescendantOf(Part)

print(IsDescendantOf)

IsA

IsA method checks if an object is of a specified class name in Lua.

Parameters

string InClassName

Return

bool

Code Samples

if Part:IsA("Part") then
    print("Part")
else
    
end

SetAttribute

Sets the value of an attribute with a specific key in it; if no attribute has that key, create and save a pair.

Parameters

string attribute

Value value

Return

void

Code Samples

local AttributeName = "Number"
local SetValue = 1
Part:SetAttribute(AttributeName, SetValue)

WaitForChild

The WaitForChild method is used to pause the execution of the script until the specified child instance with the given name is found within the parent instance. This is especially useful in situations where you need to ensure that certain objects are loaded and available before proceeding with the rest of the script. An optional timeout period can also be specified to stop waiting after the given duration.

Parameters

string InChildName

number InTimeOut

Return

Instance

Code Samples

local Workspace = game:GetService("Workspace")

local Part = Workspace:WaitForChild("Part")
print(Part)

AddTag

The AddTag method appends or adds a tag to an Instance.

Parameters

FName tag

Return

void

Code Samples

Part:AddTag("SomeTag")

RemoveTag

Removes a specified tag from an object .

Parameters

FName tag

Return

void

Code Samples

Part:RemoveTag("SomeTag")

HasTag

The HasTag method checks if an object has a specific tag.

Parameters

FName tag

Return

bool

Code Samples

if Part:HasTag("SomeTag") then
    
else
    
end

GetTags

The GetTags method retrieves a list of all the tags currently applied to an instance.

Parameters

Return

array

Code Samples

Part:AddTag("SomeTag")

local Tags = Part:GetTags()
for i = 1, #Tags do
    print(Tags[i])
end

Events

AncestryChanged

Triggered when the ancestry of the instance changes (for example, when the instance is parented to a new object or unparented).

Parameters

Code Samples

local Part = Instance.new("Part")

local function OnAncestryChanged(child, parent)
    print(child, "Ancestry Changed:", parent)
end
Part.AncestryChanged:Connect(OnAncestryChanged)

wait(2)
Part.Parent = game.Workspace

AttributeChanged

Triggered when an attribute of the instance changes.

Parameters

Code Samples

local Part = script.Parent

local function OnAttributeChanged(attribute)
    print(attribute, "Changed:", Part:GetAttribute(attribute))
end
Part.AttributeChanged:Connect(OnAttributeChanged)

wait(2)
Part:SetAttribute("Color", "Blue")

Changed

Triggered whenever a property of the instance is changed.

Parameters

Code Samples

local Part = script.Parent

local function OnChanged(property)
    print(property, "Changed:", Part[property])
end
Part.Changed:Connect(OnChanged)

wait(2)
Part.Name = "MyPart"

ChildAdded

Triggered when a new child is added to the instance.

Parameters

Code Samples

local Part = script.Parent

local function OnChildAdded(child)
    print("Child Added:", child)
end
Part.ChildAdded:Connect(OnChildAdded)

wait(2)
local ChildPart = Instance.new("Part")
ChildPart.Name = "ChildPart"
ChildPart.Parent = Part

ChildRemoved

Triggered when a child is removed from the instance.

Parameters

Code Samples

DescendantAdded

Triggered when a descendant (any child, grandchild, etc.) is added to the instance.

Parameters

Code Samples

local Part = script.Parent

local function OnDescendantAdded(descendant)
    print("Descendant Added:", descendant)
end
Part.DescendantAdded:Connect(OnDescendantAdded)

wait(2)
local ChildPart = Instance.new("Part")
ChildPart.Name = "ChildPart"
ChildPart.Parent = Part

DescendantRemoving

Triggered when a descendant (any child, grandchild, etc.) is about to be removed from the instance.

Parameters

Code Samples

Destroying

Triggered right before the instance is destroyed.

Parameters

Code Samples

local Part = script.Parent

local function OnDestroying()
    print(Part, "is being destroyed.")
end
Part.Destroying:Connect(OnDestroying)

wait(2)
Part:Destroy()
PreviousLayerCollectorNextLight

Last updated 22 days ago

📚