เรียนรู้
Engine Class
Instance
ไม่สามารถสร้าง
ไม่สามารถเรียกดู

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
คุณสมบัติ
archivable:boolean
เลิกใช้แล้ว
RobloxLocked:boolean
เลิกใช้แล้ว
UniqueId:UniqueId
วิธีการ
AddTag(tag: string):()
children():Instances
เลิกใช้แล้ว
clone():Instance
เลิกใช้แล้ว
Destroy():()
destroy():()
เลิกใช้แล้ว
findFirstChild(name: string,recursive: boolean):Instance
เลิกใช้แล้ว
GetAttribute(attribute: string):Variant
GetChildren():Instances
getChildren():Instances
เลิกใช้แล้ว
GetDebugId(scopeLength: number):string
GetDescendants():Instances
GetStyled(name: string,selector: string?):Variant
isDescendantOf(ancestor: Instance):boolean
เลิกใช้แล้ว
QueryDescendants(selector: string):Instances
Remove():()
เลิกใช้แล้ว
remove():()
เลิกใช้แล้ว
RemoveTag(tag: string):()
SetAttribute(attribute: string,value: Variant):()
WaitForChild(childName: string,timeOut: number):Instance
สมาชิกที่ได้รับทอด
ได้รับทอดโดย
AccessoryDescription, Accoutrement, AdPortal, AdService, AdvancedDragger,

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Archivable
อ่านพร้อมๆ กัน
Instance.Archivable:boolean

archivable
เลิกใช้แล้ว

Capabilities
อ่านพร้อมๆ กัน
ความสามารถ: CapabilityControl
Instance.Capabilities:SecurityCapabilities

Name
อ่านพร้อมๆ กัน
Instance.Name:string

Parent
ไม่ซ้ำ
อ่านพร้อมๆ กัน
Instance.Parent:Instance

PredictionMode
อ่านอย่างเดียว
ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน
Instance.PredictionMode:Enum.PredictionMode

RobloxLocked
เลิกใช้แล้ว

Sandboxed
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: CapabilityControl
Instance.Sandboxed:boolean

UniqueId
ไม่ซ้ำ
การรักษาความปลอดภัยของสคริปต์ Roblox
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
Instance.UniqueId:UniqueId

วิธีการ
AddTag
Instance:AddTag(tag:string):()
พารามิเตอร์
tag:string
ส่งค่ากลับ
()

children
เลิกใช้แล้ว

ClearAllChildren
Instance:ClearAllChildren():()
ส่งค่ากลับ
()

Clone
ความสามารถ: CreateInstances
การเข้าถึงการจำลองสถานการณ์
Instance:Clone():Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
การโคลนอินสแตนซ์
local Workspace = game:GetService("Workspace")
-- รับการอ้างอิงถึงวัตถุที่มีอยู่
local model = script.Parent.Model
-- สร้างโคลนของโมเดล
local clone = model:Clone()
-- ย้ายโคลนให้ไม่ทับซ้อนกับโมเดลดั้งเดิม
clone:PivotTo(model.PrimaryPart.CFrame - (Vector3.xAxis * 10))
-- เพิ่มโคลนไปยัง Workspace
clone.Parent = Workspace

clone
เลิกใช้แล้ว

Destroy
Instance:Destroy():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
อินสแตนซ์:Destroy()
local part = script.Parent.Part
part:Destroy()

destroy
เลิกใช้แล้ว

FindFirstAncestor
เขียนพร้อมๆ กัน
Instance:FindFirstAncestor(name:string):Instance?
พารามิเตอร์
name:string
ส่งค่ากลับ

FindFirstAncestorOfClass
เขียนพร้อมๆ กัน
Instance:FindFirstAncestorOfClass(className:string):Instance?
พารามิเตอร์
className:string
ส่งค่ากลับ

FindFirstAncestorWhichIsA
เขียนพร้อมๆ กัน
Instance:FindFirstAncestorWhichIsA(className:string):Instance?
พารามิเตอร์
className:string
ส่งค่ากลับ

FindFirstChild
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:FindFirstChild(
name:string, recursive:boolean
พารามิเตอร์
name:string
recursive:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ
ตัวอย่างโค้ด
Instance:FindFirstChild
local found = workspace:FindFirstChild("Brick")
if found then
found.Name = "Foo"
end

findFirstChild
เลิกใช้แล้ว

FindFirstChildOfClass
เขียนพร้อมๆ กัน
Instance:FindFirstChildOfClass(className:string):Instance?
พารามิเตอร์
className:string
ส่งค่ากลับ
ตัวอย่างโค้ด
อินสแตนซ์:หาเด็กแรกเกิดของคลาส
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
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:FindFirstChildWhichIsA(
className:string, recursive:boolean
พารามิเตอร์
className:string
recursive:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ

FindFirstDescendant
เขียนพร้อมๆ กัน
Instance:FindFirstDescendant(name:string):Instance?
พารามิเตอร์
name:string
ส่งค่ากลับ

GetActor
เขียนพร้อมๆ กัน
Instance:GetActor():Actor?
ส่งค่ากลับ

GetAttribute
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetAttribute(attribute:string):Variant
พารามิเตอร์
attribute:string
ส่งค่ากลับ
Variant

GetAttributeChangedSignal
Instance:GetAttributeChangedSignal(attribute:string):RBXScriptSignal
พารามิเตอร์
attribute:string
ส่งค่ากลับ

GetAttributes
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetAttributes():Dictionary
ส่งค่ากลับ

GetChildren
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetChildren():Instances
ส่งค่ากลับ
Instances
ตัวอย่างโค้ด
Instance:GetChildren
local children = workspace:GetChildren()
for i = 1, #children do
print(i, children[i].Name)
end

getChildren
เลิกใช้แล้ว

GetDebugId
ไม่สามารถเรียกดู
การรักษาความปลอดภัยของปลั๊กอิน
Instance:GetDebugId(scopeLength:number):string
พารามิเตอร์
scopeLength:number
ค่าเริ่มต้น: 4
ส่งค่ากลับ
ตัวอย่างโค้ด
Instance:GetDebugId
print(workspace:GetDebugId()) --> 39FA_12
print(workspace:GetDebugId(10)) --> 39FA2FEF4D_12
print(workspace:GetDebugId(math.huge)) --> 12

GetDescendants
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetDescendants():Instances
ส่งค่ากลับ
Instances
ตัวอย่างโค้ด
Instance:GetDescendants
local descendants = workspace:GetDescendants()
-- วนลูปผ่านทายาททั้งหมดของ Workspace ถ้าพบ
-- BasePart โค้ดจะเปลี่ยนสีของส่วนที่นั่นเป็นสีเขียว
for _, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end

GetFullName
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetFullName():string
ส่งค่ากลับ
ตัวอย่างโค้ด
Instance:GetFullName
-- สร้างโครงสร้างพื้นฐานแบบง่าย
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 = "สวัสดี, โลก"
print(fire:GetFullName()) --> Workspace.Model.สวัสดี, โลก.Fire
การใช้ Lua ในการนำเสนอตัวเต็ม: Instance:GetFullName
local function getFullName(object)
local result = object.Name
object = object.Parent
while object and object ~= game do
-- ใส่ชื่อของพ่อแม่ไว้ข้างหน้า
result = object.Name .. "." .. result
-- ขึ้นไปยังลำดับชั้น
object = object.Parent
end
return result
end
print(getFullName(workspace.Camera)) --> Workspace.Camera

GetStyled
Instance:GetStyled(
name:string, selector:string?
):Variant
พารามิเตอร์
name:string
selector:string?
ส่งค่ากลับ
Variant

GetStyledPropertyChangedSignal
Instance:GetStyledPropertyChangedSignal(property:string):RBXScriptSignal
พารามิเตอร์
property:string
ส่งค่ากลับ

GetTags
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:GetTags():{any}
ส่งค่ากลับ

HasTag
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:HasTag(tag:string):boolean
พารามิเตอร์
tag:string
ส่งค่ากลับ

IsAncestorOf
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:IsAncestorOf(descendant:Instance):boolean
พารามิเตอร์
descendant:Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
Instance:IsAncestorOf()
local Workspace = game:GetService("Workspace")
local spawnLocation = Workspace.SpawnLocation
local decal = spawnLocation.Decal
-- ข้อความเหล่านี้เป็นจริง
print(Workspace:IsAncestorOf(spawnLocation))
print(Workspace:IsAncestorOf(decal))
print(spawnLocation:IsAncestorOf(decal))
-- ข้อความเหล่านี้เป็นเท็จ
print(spawnLocation:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(spawnLocation))

IsDescendantOf
เขียนพร้อมๆ กัน
การเข้าถึงการจำลองสถานการณ์
Instance:IsDescendantOf(ancestor:Instance):boolean
พารามิเตอร์
ancestor:Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
Instance:IsDescendantOf
local part = Instance.new("Part")
print(part:IsDescendantOf(game))
--> เท็จ
part.Parent = workspace
print(part:IsDescendantOf(game))
--> จริง
part.Parent = game
print(part:IsDescendantOf(game))
--> จริง

isDescendantOf
เลิกใช้แล้ว

IsPropertyModified
การเข้าถึงการจำลองสถานการณ์
Instance:IsPropertyModified(property:string):boolean
พารามิเตอร์
property:string
ส่งค่ากลับ

QueryDescendants
การเข้าถึงการจำลองสถานการณ์
Instance:QueryDescendants(selector:string):Instances
พารามิเตอร์
selector:string
ส่งค่ากลับ
Instances

Remove
เลิกใช้แล้ว

remove
เลิกใช้แล้ว

RemoveTag
Instance:RemoveTag(tag:string):()
พารามิเตอร์
tag:string
ส่งค่ากลับ
()

ResetPropertyToDefault
Instance:ResetPropertyToDefault(property:string):()
พารามิเตอร์
property:string
ส่งค่ากลับ
()

SetAttribute
การเข้าถึงการจำลองสถานการณ์
Instance:SetAttribute(
attribute:string, value:Variant
):()
พารามิเตอร์
attribute:string
value:Variant
ส่งค่ากลับ
()

WaitForChild
อาจให้
Instance:WaitForChild(
childName:string, timeOut:number
พารามิเตอร์
childName:string
timeOut:number
ส่งค่ากลับ
ตัวอย่างโค้ด
อินสแตนซ์: รอสำหรับลูก
local part = workspace:WaitForChild("Part")
print(part.Name .. " ได้ถูกเพิ่มไปที่ Workspace")

เหตุการณ์
AncestryChanged
Instance.AncestryChanged(
child:Instance, parent:Instance
พารามิเตอร์
child:Instance
parent:Instance
ตัวอย่างโค้ด
Instance.AncestryChanged
local Workspace = game:GetService("Workspace")
local redPart = script.Parent.RedPart
local bluePart = script.Parent.BluePart
local changingPart = script.Parent.ChangingPart
-- เปลี่ยนสีของ changingPart ตาม Parent
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} ตอนนี้ถูกตั้งเป็น Parent ที่ {parent.Name}`)
end
changingPart.AncestryChanged:Connect(onAncestryChanged)
-- ตั้งค่า Parent ของ changingPart ให้เป็นอินสแตนซ์ต่าง ๆ เมื่อเวลาผ่านไป
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
พารามิเตอร์
attribute:string

ChildAdded
Instance.ChildAdded(child:Instance):RBXScriptSignal
พารามิเตอร์
child:Instance
ตัวอย่างโค้ด
Instance.ChildAdded
local function onChildAdded(instance)
print(instance.Name .. " ถูกเพิ่มเข้ามาใน workspace")
end
workspace.ChildAdded:Connect(onChildAdded)
local part = Instance.new("Part")
part.Parent = workspace --> Part ถูกเพิ่มเข้ามาใน Workspace

childAdded
เลิกใช้แล้ว

ChildRemoved
Instance.ChildRemoved(child:Instance):RBXScriptSignal
พารามิเตอร์
child:Instance
ตัวอย่างโค้ด
Instance.ChildRemoved
local function onChildRemoved(instance)
print(instance.Name .. " ถูกลบออกจาก 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
พารามิเตอร์
descendant:Instance
ตัวอย่างโค้ด
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
พารามิเตอร์
descendant:Instance
ตัวอย่างโค้ด
Instance.DescendantRemoving
workspace.DescendantRemoving:Connect(function(descendant)
print(descendant.Name .. " กำลังถูกพ่อแม่เป็น " .. tostring(descendant.Parent))
end)
local part = Instance.new("Part")
part.Parent = workspace
part.Parent = nil
--> Part กำลังถูกพ่อแม่เป็น Workspace
print(part.Parent)
--> nil

Destroying
Instance.Destroying():RBXScriptSignal
ตัวอย่างโค้ด
การใช้เหตุการณ์การทำลาย (สัญญาณทันที)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("ก่อนที่จะหยุดทำงาน:", part:GetFullName(), #part:GetChildren())
task.wait()
print("หลังจากหยุดทำงาน:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
part:Destroy()
การใช้เหตุการณ์การทำลาย (สัญญาณที่ล่าช้า)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("ในสัญญาณ:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
print("ก่อนการทำลาย:", part:GetFullName(), #part:GetChildren())
part:Destroy()
print("หลังการทำลาย:", part:GetFullName(), #part:GetChildren())

StyledPropertiesChanged
Instance.StyledPropertiesChanged():RBXScriptSignal

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ