Ghi chú phát hành
Học
Lớp công cụ
Instance
Không Thể Tạo
Không Thể Duyệt

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
AddTag(tag: string):()
children():Instances
Đã Lỗi Thời
clone():Instance
Đã Lỗi Thời
Destroy():()
destroy():()
Đã Lỗi Thời
findFirstChild(name: string,recursive: boolean):Instance
Đã Lỗi Thời
GetAttribute(attribute: string):Variant
GetChildren():Instances
getChildren():Instances
Đã Lỗi Thời
GetDebugId(scopeLength: number):string
GetDescendants():Instances
GetStyled(name: string,selector: string?):Variant
isDescendantOf(ancestor: Instance):boolean
Đã Lỗi Thời
QueryDescendants(selector: string):Instances
Remove():()
Đã Lỗi Thời
remove():()
Đã Lỗi Thời
RemoveTag(tag: string):()
SetAttribute(attribute: string,value: Variant):()
WaitForChild(childName: string,timeOut: number):Instance
Thành viên kế thừa
Được kế thừa bởi

Tài Liệu Tham Khảo API
Thuộc Tính
Archivable
Đọc Song Song
Instance.Archivable:boolean

archivable
Đã Lỗi Thời

Capabilities
Đọc Song Song
Các khả năng: CapabilityControl
Instance.Capabilities:SecurityCapabilities

Name
Đọc Song Song
Instance.Name:string

Parent
Không Sao Chép
Đọc Song Song
Instance.Parent:Instance

PredictionMode
Chỉ Đọc
Không Sao Chép
Không Thể Viết Kịch Bản
Đọc Song Song
Instance.PredictionMode:Enum.PredictionMode

RobloxLocked
Đã Lỗi Thời

Sandboxed
Không Sao Chép
Đọc Song Song
Các khả năng: CapabilityControl
Instance.Sandboxed:boolean

UniqueId
Không Sao Chép
Bảo Mật Kịch Bản Roblox
Bảo Mật Roblox
Đọc Song Song
Instance.UniqueId:UniqueId

Phương Pháp
AddTag
Instance:AddTag(tag:string):()
Tham Số
tag:string
Lợi Nhuận
()

children
Đã Lỗi Thời

ClearAllChildren
Instance:ClearAllChildren():()
Lợi Nhuận
()

Clone
Các khả năng: CreateInstances
Quyền sử dụng chế độ mô phỏng
Instance:Clone():Instance
Lợi Nhuận
Mẫu mã
Nhân bản một Thể Instance
local Workspace = game:GetService("Workspace")
-- Lấy tham chiếu đến một đối tượng đã tồn tại
local model = script.Parent.Model
-- Tạo một bản sao của mô hình
local clone = model:Clone()
-- Di chuyển bản sao sao cho nó không chồng lên mô hình gốc
clone:PivotTo(model.PrimaryPart.CFrame - (Vector3.xAxis * 10))
-- Thêm bản sao vào Workspace
clone.Parent = Workspace

clone
Đã Lỗi Thời

Destroy
Instance:Destroy():()
Lợi Nhuận
()
Mẫu mã
Thành phần:Giết()
local part = script.Parent.Part
part:Destroy()

destroy
Đã Lỗi Thời

FindFirstAncestor
Ghi Song Song
Instance:FindFirstAncestor(name:string):Instance?
Tham Số
name:string
Lợi Nhuận

FindFirstAncestorOfClass
Ghi Song Song
Instance:FindFirstAncestorOfClass(className:string):Instance?
Tham Số
className:string
Lợi Nhuận

FindFirstAncestorWhichIsA
Ghi Song Song
Instance:FindFirstAncestorWhichIsA(className:string):Instance?
Tham Số
className:string
Lợi Nhuận

FindFirstChild
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:FindFirstChild(
name:string, recursive:boolean
Tham Số
name:string
recursive:boolean
Giá Trị Mặc Định: false
Lợi Nhuận
Mẫu mã
Instance:FindFirstChild
local found = workspace:FindFirstChild("Brick")
if found then
found.Name = "Foo"
end

findFirstChild
Đã Lỗi Thời

FindFirstChildOfClass
Ghi Song Song
Instance:FindFirstChildOfClass(className:string):Instance?
Tham Số
className:string
Lợi Nhuận
Mẫu mã
Thể hiện: TìmCháuĐầuTiênCủaLớp
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid
while not humanoid do
humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then
character.ChildAdded:Wait()
end
end

FindFirstChildWhichIsA
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:FindFirstChildWhichIsA(
className:string, recursive:boolean
Tham Số
className:string
recursive:boolean
Giá Trị Mặc Định: false
Lợi Nhuận

FindFirstDescendant
Ghi Song Song
Instance:FindFirstDescendant(name:string):Instance?
Tham Số
name:string
Lợi Nhuận

GetActor
Ghi Song Song
Instance:GetActor():Actor?
Lợi Nhuận

GetAttribute
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetAttribute(attribute:string):Variant
Tham Số
attribute:string
Lợi Nhuận
Variant

GetAttributeChangedSignal
Instance:GetAttributeChangedSignal(attribute:string):RBXScriptSignal
Tham Số
attribute:string
Lợi Nhuận

GetAttributes
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetAttributes():Dictionary
Lợi Nhuận

GetChildren
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetChildren():Instances
Lợi Nhuận
Instances
Mẫu mã
Instance:GetChildren
local children = workspace:GetChildren()
for i = 1, #children do
print(i, children[i].Name)
end

getChildren
Đã Lỗi Thời

GetDebugId
Không Thể Duyệt
Bảo Mật Plugin
Instance:GetDebugId(scopeLength:number):string
Tham Số
scopeLength:number
Giá Trị Mặc Định: 4
Lợi Nhuận
Mẫu mã
Thể hiện: Lấy ID gỡ lỗi
print(workspace:GetDebugId()) --> 39FA_12
print(workspace:GetDebugId(10)) --> 39FA2FEF4D_12
print(workspace:GetDebugId(math.huge)) --> 12

GetDescendants
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetDescendants():Instances
Lợi Nhuận
Instances
Mẫu mã
Instance:GetDescendants
local descendants = workspace:GetDescendants()
-- Lặp qua tất cả các hậu duệ của Workspace. Nếu một
-- BasePart được tìm thấy, đoạn mã sẽ đổi màu của phần đó thành màu xanh lá cây
for _, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end

GetFullName
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetFullName():string
Lợi Nhuận
Mẫu mã
Instance:GetFullName
-- Tạo một hệ thống phân cấp đơn giản
local model = Instance.new("Model")
local part = Instance.new("Part")
part.Parent = model
local fire = Instance.new("Fire")
fire.Parent = part
print(fire:GetFullName()) --> Model.Part.Fire
model.Parent = workspace
print(fire:GetFullName()) --> Workspace.Model.Part.Fire
part.Name = "Xin chào, thế giới"
print(fire:GetFullName()) --> Workspace.Model.Xin chào, thế giới.Fire
Cài đặt Lua của Instance:GetFullName
local function getFullName(object)
local result = object.Name
object = object.Parent
while object and object ~= game do
-- Thêm tên cha vào trước
result = object.Name .. "." .. result
-- Đi lên cấu trúc phân cấp
object = object.Parent
end
return result
end
print(getFullName(workspace.Camera)) --> Workspace.Camera

GetStyled
Instance:GetStyled(
name:string, selector:string?
):Variant
Tham Số
name:string
selector:string?
Lợi Nhuận
Variant

GetStyledPropertyChangedSignal
Instance:GetStyledPropertyChangedSignal(property:string):RBXScriptSignal
Tham Số
property:string
Lợi Nhuận

GetTags
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:GetTags():{any}
Lợi Nhuận

HasTag
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:HasTag(tag:string):boolean
Tham Số
tag:string
Lợi Nhuận

IsAncestorOf
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:IsAncestorOf(descendant:Instance):boolean
Tham Số
descendant:Instance
Lợi Nhuận
Mẫu mã
Instance:IsAncestorOf()
local Workspace = game:GetService("Workspace")
local spawnLocation = Workspace.SpawnLocation
local decal = spawnLocation.Decal
-- Các câu lệnh này là đúng
print(Workspace:IsAncestorOf(spawnLocation))
print(Workspace:IsAncestorOf(decal))
print(spawnLocation:IsAncestorOf(decal))
-- Các câu lệnh này là sai
print(spawnLocation:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(spawnLocation))

IsDescendantOf
Ghi Song Song
Quyền sử dụng chế độ mô phỏng
Instance:IsDescendantOf(ancestor:Instance):boolean
Tham Số
ancestor:Instance
Lợi Nhuận
Mẫu mã
Instance:IsDescendantOf
local part = Instance.new("Part")
print(part:IsDescendantOf(game))
--> sai
part.Parent = workspace
print(part:IsDescendantOf(game))
--> đúng
part.Parent = game
print(part:IsDescendantOf(game))
--> đúng

isDescendantOf
Đã Lỗi Thời

IsPropertyModified
Quyền sử dụng chế độ mô phỏng
Instance:IsPropertyModified(property:string):boolean
Tham Số
property:string
Lợi Nhuận

QueryDescendants
Quyền sử dụng chế độ mô phỏng
Instance:QueryDescendants(selector:string):Instances
Tham Số
selector:string
Lợi Nhuận
Instances

Remove
Đã Lỗi Thời

remove
Đã Lỗi Thời

RemoveTag
Instance:RemoveTag(tag:string):()
Tham Số
tag:string
Lợi Nhuận
()

ResetPropertyToDefault
Instance:ResetPropertyToDefault(property:string):()
Tham Số
property:string
Lợi Nhuận
()

SetAttribute
Quyền sử dụng chế độ mô phỏng
Instance:SetAttribute(
attribute:string, value:Variant
):()
Tham Số
attribute:string
value:Variant
Lợi Nhuận
()

WaitForChild
Có Thể Sinh Lợi
Instance:WaitForChild(
childName:string, timeOut:number
Tham Số
childName:string
timeOut:number
Lợi Nhuận
Mẫu mã
Thể hiện:Chờ Con
local part = workspace:WaitForChild("Part")
print(part.Name .. " đã được thêm vào Workspace")

Sự Kiện
AncestryChanged
Instance.AncestryChanged(
child:Instance, parent:Instance
Tham Số
child:Instance
parent:Instance
Mẫu mã
Instance.AncestryChanged
local Workspace = game:GetService("Workspace")
local redPart = script.Parent.RedPart
local bluePart = script.Parent.BluePart
local changingPart = script.Parent.ChangingPart
-- Thay đổi màu của changingPart dựa trên Parent của nó
local function onAncestryChanged(part: Part, parent: Instance)
if parent == redPart then
changingPart.Color = Color3.new(1, 0, 0)
elseif parent == bluePart then
changingPart.Color = Color3.new(0, 0, 1)
else
changingPart.Color = Color3.new(1, 1, 1)
end
print(`{part.Name} giờ đây được gán là con của {parent.Name}`)
end
changingPart.AncestryChanged:Connect(onAncestryChanged)
-- Đặt thuộc tính Parent của changingPart thành các instance khác nhau theo thời gian
while true do
task.wait(2)
changingPart.Parent = redPart
task.wait(2)
changingPart.Parent = bluePart
task.wait(2)
changingPart.Parent = Workspace
end

AttributeChanged
Instance.AttributeChanged(attribute:string):RBXScriptSignal
Tham Số
attribute:string

ChildAdded
Instance.ChildAdded(child:Instance):RBXScriptSignal
Tham Số
child:Instance
Mẫu mã
Instance.ChildAdded
local function onChildAdded(instance)
print(instance.Name .. " đã được thêm vào workspace")
end
workspace.ChildAdded:Connect(onChildAdded)
local part = Instance.new("Part")
part.Parent = workspace --> Phần đã được thêm vào Workspace

childAdded
Đã Lỗi Thời

ChildRemoved
Instance.ChildRemoved(child:Instance):RBXScriptSignal
Tham Số
child:Instance
Mẫu mã
Instance.ChildRemoved
local function onChildRemoved(instance)
print(instance.Name .. " bị xóa khỏi workspace")
end
workspace.ChildRemoved:Connect(onChildRemoved)
local part = Instance.new("Part")
part.Parent = workspace
task.wait(2)
part:Destroy()

DescendantAdded
Instance.DescendantAdded(descendant:Instance):RBXScriptSignal
Tham Số
descendant:Instance
Mẫu mã
Instance.DescendantAdded
local function onDescendantAdded(descendant)
print(descendant)
end
workspace.DescendantAdded:Connect(onDescendantAdded)
local part = Instance.new("Part")
part.Parent = workspace

DescendantRemoving
Instance.DescendantRemoving(descendant:Instance):RBXScriptSignal
Tham Số
descendant:Instance
Mẫu mã
Instance.DescendantRemoving
workspace.DescendantRemoving:Connect(function(descendant)
print(descendant.Name .. " hiện đang thuộc về " .. tostring(descendant.Parent))
end)
local part = Instance.new("Part")
part.Parent = workspace
part.Parent = nil
--> Phần hiện đang thuộc về Workspace
print(part.Parent)
--> nil

Destroying
Instance.Destroying():RBXScriptSignal
Mẫu mã
Sử dụng sự kiện Phá hủy (Tín hiệu ngay lập tức)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("Trước khi dừng lại:", part:GetFullName(), #part:GetChildren())
task.wait()
print("Sau khi dừng lại:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
part:Destroy()
Sử dụng Sự kiện Hủy (Tín hiệu Hoãn)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("Trong tín hiệu:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
print("Trước khi hủy:", part:GetFullName(), #part:GetChildren())
part:Destroy()
print("Sau khi hủy:", part:GetFullName(), #part:GetChildren())

StyledPropertiesChanged
Instance.StyledPropertiesChanged():RBXScriptSignal

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.