Instance

Artık kullanılmayanları göster

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.

Oluşturulamaz
Gezilemez

Instance Roblox sınıf hiyerarşisindeki tüm sınıfların temel sınıfıdır, DataModel ağacının bir parçası olabilir.

Doğrudan kök Instance nesneler oluşturmak mümkün değildir, ancak özel Instance.new() yapıcı kod aracılığıyla nesneler oluşturur ve sınıfın adını bir parametre olarak alır ve oluşturulan nesneyi geri verir.

Özet

Özellikler

  • Paralel oku

    Bir Instance ve onun soyundakilerin Instance:Clone() kullanarak klonlanıp kaydedilebileceğini veya yayınlanabileceğini belirler.

  • Capabilities:SecurityCapabilities
    Paralel oku

    Bu kapsayıcının içinde kullanılabilecek yeteneklerin seti.

  • Paralel oku

    Eşsiz olmayan bir tanımlayıcı Instance .

  • Çoğaltılmamış
    Paralel oku

    Instance 'nin hiyerarşik ebeveynini belirler.

  • Gizli
    Eklenti Güvenliği
    Paralel oku
    Artık Kullanılmayan

    CoreGui nesnelerini korumak için kullanılan eski bir özellik.

  • Çoğaltılmamış
    Paralel oku

    Instansı bir kumlanmış kutu olarak dönüştürür.

  • UniqueId:UniqueId
    Çoğaltılmamış
    Betiklenemez
    Roblox Güvenliği
    Paralel oku

    İstisna için benzersiz bir tanımlayıcı.

Yöntemler

Olaylar

Özellikler

Archivable

Paralel oku

Capabilities

SecurityCapabilities
Paralel oku

Name

Paralel oku

Parent

Çoğaltılmamış
Paralel oku

RobloxLocked

Gizli
Eklenti Güvenliği
Paralel oku

Sandboxed

Çoğaltılmamış
Paralel oku

UniqueId

UniqueId
Çoğaltılmamış
Betiklenemez
Roblox Güvenliği
Paralel oku

Yöntemler

AddTag

()

Parametreler

tag: string
Varsayılan değer: ""

Dönüşler

()

ClearAllChildren

()

Dönüşler

()

Dönüşler

Kod Örnekleri

Cloning an Instance

local Workspace = game:GetService("Workspace")
-- Get a reference to an existing object
local model = script.Parent.Model
-- Create a clone of the model
local clone = model:Clone()
-- Move the clone so it's not overlapping the original model
clone:PivotTo(model.PrimaryPart.CFrame - (Vector3.xAxis * 10))
-- Add the clone to the Workspace
clone.Parent = Workspace

Destroy

()

Dönüşler

()

Kod Örnekleri

Instance:Destroy()

local part = script.Parent.Part
part:Destroy()

FindFirstAncestor

Paralel yaz

Parametreler

name: string
Varsayılan değer: ""

Dönüşler

FindFirstAncestorOfClass

Paralel yaz

Parametreler

className: string
Varsayılan değer: ""

Dönüşler

FindFirstAncestorWhichIsA

Paralel yaz

Parametreler

className: string
Varsayılan değer: ""

Dönüşler

FindFirstChild

Paralel yaz

Parametreler

name: string
Varsayılan değer: ""
recursive: boolean
Varsayılan değer: false

Dönüşler

Kod Örnekleri

Instance:FindFirstChild

local found = workspace:FindFirstChild("Brick")
if found then
found.Name = "Foo"
end

FindFirstChildOfClass

Paralel yaz

Parametreler

className: string
Varsayılan değer: ""

Dönüşler

Kod Örnekleri

Instance:FindFirstChildOfClass

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

Paralel yaz

Parametreler

className: string
Varsayılan değer: ""
recursive: boolean
Varsayılan değer: false

Dönüşler

FindFirstDescendant

Paralel yaz

Parametreler

name: string
Varsayılan değer: ""

Dönüşler

GetActor

Paralel yaz

Dönüşler

GetAttribute

Variant
Paralel yaz

Parametreler

attribute: string
Varsayılan değer: ""

Dönüşler

Variant

GetAttributeChangedSignal

Parametreler

attribute: string
Varsayılan değer: ""

Dönüşler

GetAttributes

Paralel yaz

Dönüşler

GetChildren

Instances
Paralel yaz

Dönüşler

Instances

Kod Örnekleri

Instance:GetChildren

local children = workspace:GetChildren()
for i = 1, #children do
print(i, children[i].Name)
end

GetDebugId

Gezilemez
Eklenti Güvenliği

Parametreler

scopeLength: number
Varsayılan değer: 4

Dönüşler

Kod Örnekleri

Instance:GetDebugId

print(workspace:GetDebugId()) --> 39FA_12
print(workspace:GetDebugId(10)) --> 39FA2FEF4D_12
print(workspace:GetDebugId(math.huge)) --> 12

GetDescendants

Paralel yaz

Dönüşler

Kod Örnekleri

Instance:GetDescendants

local descendants = workspace:GetDescendants()
-- Loop through all of the descendants of the Workspace. If a
-- BasePart is found, the code changes that parts color to green
for _, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end

GetFullName

Paralel yaz

Dönüşler

Kod Örnekleri

Instance:GetFullName

-- Create a simple hierarchy
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 = "Hello, world"
print(fire:GetFullName()) --> Workspace.Model.Hello, world.Fire
Instance:GetFullName Lua Implementation

local function getFullName(object)
local result = object.Name
object = object.Parent
while object and object ~= game do
-- Prepend parent name
result = object.Name .. "." .. result
-- Go up the hierarchy
object = object.Parent
end
return result
end
print(getFullName(workspace.Camera)) --> Workspace.Camera

GetStyled

Variant

Parametreler

name: string
Varsayılan değer: ""

Dönüşler

Variant

GetStyledPropertyChangedSignal

Parametreler

property: string
Varsayılan değer: ""

Dönüşler

GetTags

Paralel yaz

Dönüşler

HasTag

Paralel yaz

Parametreler

tag: string
Varsayılan değer: ""

Dönüşler

IsAncestorOf

Paralel yaz

Parametreler

descendant: Instance
Varsayılan değer: ""

Dönüşler

Kod Örnekleri

Instance:IsAncestorOf()

local Workspace = game:GetService("Workspace")
local spawnLocation = Workspace.SpawnLocation
local decal = spawnLocation.Decal
-- These statements are true
print(Workspace:IsAncestorOf(spawnLocation))
print(Workspace:IsAncestorOf(decal))
print(spawnLocation:IsAncestorOf(decal))
-- These statements are false
print(spawnLocation:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(spawnLocation))

IsDescendantOf

Paralel yaz

Parametreler

ancestor: Instance
Varsayılan değer: ""

Dönüşler

Kod Örnekleri

Instance:IsDescendantOf

local part = Instance.new("Part")
print(part:IsDescendantOf(game))
--> false
part.Parent = workspace
print(part:IsDescendantOf(game))
--> true
part.Parent = game
print(part:IsDescendantOf(game))
--> true

IsPropertyModified

Parametreler

property: string
Varsayılan değer: ""

Dönüşler

RemoveTag

()

Parametreler

tag: string
Varsayılan değer: ""

Dönüşler

()

ResetPropertyToDefault

()

Parametreler

property: string
Varsayılan değer: ""

Dönüşler

()

SetAttribute

()

Parametreler

attribute: string
Varsayılan değer: ""
value: Variant
Varsayılan değer: ""

Dönüşler

()

WaitForChild

Bekletebilir

Parametreler

childName: string
Varsayılan değer: ""
timeOut: number
Varsayılan değer: ""

Dönüşler

Kod Örnekleri

Instance:WaitForChild

local part = workspace:WaitForChild("Part")
print(part.Name .. " has been added to the Workspace")

Olaylar

AncestryChanged

Parametreler

child: Instance
parent: Instance

Kod Örnekleri

Instance.AncestryChanged

local Workspace = game:GetService("Workspace")
local redPart = script.Parent.RedPart
local bluePart = script.Parent.BluePart
local changingPart = script.Parent.ChangingPart
-- Change the color of changingPart based on it's 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} is now parented to {parent.Name}`)
end
changingPart.AncestryChanged:Connect(onAncestryChanged)
-- Set changingPart's Parent property to different instances over time
while true do
task.wait(2)
changingPart.Parent = redPart
task.wait(2)
changingPart.Parent = bluePart
task.wait(2)
changingPart.Parent = Workspace
end

AttributeChanged

Parametreler

attribute: string

ChildAdded

Parametreler

child: Instance

Kod Örnekleri

Instance.ChildAdded

local function onChildAdded(instance)
print(instance.Name .. " added to the workspace")
end
workspace.ChildAdded:Connect(onChildAdded)
local part = Instance.new("Part")
part.Parent = workspace --> Part added to the Workspace

ChildRemoved

Parametreler

child: Instance

Kod Örnekleri

Instance.ChildRemoved

local function onChildRemoved(instance)
print(instance.Name .. " removed from the workspace")
end
workspace.ChildRemoved:Connect(onChildRemoved)
local part = Instance.new("Part")
part.Parent = workspace
task.wait(2)
part:Destroy()

DescendantAdded

Parametreler

descendant: Instance

Kod Örnekleri

Instance.DescendantAdded

local function onDescendantAdded(descendant)
print(descendant)
end
workspace.DescendantAdded:Connect(onDescendantAdded)
local part = Instance.new("Part")
part.Parent = workspace

DescendantRemoving

Parametreler

descendant: Instance

Kod Örnekleri

Instance.DescendantRemoving

workspace.DescendantRemoving:Connect(function(descendant)
print(descendant.Name .. " is currently parented to " .. tostring(descendant.Parent))
end)
local part = Instance.new("Part")
part.Parent = workspace
part.Parent = nil
--> Part is currently parented to Workspace
print(part.Parent)
--> nil

Destroying


Kod Örnekleri

Using the Destroying Event (Immediate signals)

local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("Before yielding:", part:GetFullName(), #part:GetChildren())
task.wait()
print("After yielding:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
part:Destroy()
Using the Destroying Event (Deferred signals)

local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("In signal:", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
print("Before destroying:", part:GetFullName(), #part:GetChildren())
part:Destroy()
print("After destroying:", part:GetFullName(), #part:GetChildren())

StyledPropertiesChanged