Apprendre
Classe de moteur
Instance
Création impossible
Non navigable

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.


Résumé
Méthodes
AddTag(tag: string):()
children():Instances
Déprécié
clone():Instance
Déprécié
Destroy():()
destroy():()
Déprécié
findFirstChild(name: string,recursive: boolean):Instance
Déprécié
GetAttribute(attribute: string):Variant
GetChildren():Instances
getChildren():Instances
Déprécié
GetDebugId(scopeLength: number):string
GetDescendants():Instances
GetStyled(name: string,selector: string?):Variant
isDescendantOf(ancestor: Instance):boolean
Déprécié
QueryDescendants(selector: string):Instances
Remove():()
Déprécié
remove():()
Déprécié
RemoveTag(tag: string):()
SetAttribute(attribute: string,value: Variant):()
WaitForChild(childName: string,timeOut: number):Instance
Membres hérités

Référence API
Propriétés
Archivable
Lecture parallèle
Instance.Archivable:boolean

archivable
Déprécié

Capabilities
Lecture parallèle
Capacités : CapabilityControl
Instance.Capabilities:SecurityCapabilities

Name
Lecture parallèle
Instance.Name:string

Parent
Non répliqué
Lecture parallèle
Instance.Parent:Instance

PredictionMode
Lecture uniquement
Non répliqué
Non scriptable
Lecture parallèle
Instance.PredictionMode:Enum.PredictionMode

RobloxLocked
Déprécié

Sandboxed
Non répliqué
Lecture parallèle
Capacités : CapabilityControl
Instance.Sandboxed:boolean

UniqueId
Non répliqué
Sécurité des scripts Roblox
Sécurité Roblox
Lecture parallèle
Instance.UniqueId:UniqueId

Méthodes
AddTag
Instance:AddTag(tag:string):()
Paramètres
tag:string
Retours
()

children
Déprécié

ClearAllChildren
Instance:ClearAllChildren():()
Retours
()

Clone
Capacités : CreateInstances
Accès à la simulation
Instance:Clone():Instance
Retours
Échantillons de code
Cloner une Instance
local Workspace = game:GetService("Workspace")
-- Obtenir une référence à un objet existant
local model = script.Parent.Model
-- Créer un clone du modèle
local clone = model:Clone()
-- Déplacer le clone afin qu'il ne chevauche pas le modèle original
clone:PivotTo(model.PrimaryPart.CFrame - (Vector3.xAxis * 10))
-- Ajouter le clone au Workspace
clone.Parent = Workspace

clone
Déprécié

Destroy
Instance:Destroy():()
Retours
()
Échantillons de code
Instance:Destroy()
local part = script.Parent.Part
part:Destroy()

destroy
Déprécié

FindFirstAncestor
Écrire en parallèle
Instance:FindFirstAncestor(name:string):Instance?
Paramètres
name:string
Retours

FindFirstAncestorOfClass
Écrire en parallèle
Instance:FindFirstAncestorOfClass(className:string):Instance?
Paramètres
className:string
Retours

FindFirstAncestorWhichIsA
Écrire en parallèle
Instance:FindFirstAncestorWhichIsA(className:string):Instance?
Paramètres
className:string
Retours

FindFirstChild
Écrire en parallèle
Accès à la simulation
Instance:FindFirstChild(
name:string, recursive:boolean
Paramètres
name:string
recursive:boolean
Valeur par défaut : false
Retours
Échantillons de code
Instance:FindFirstChild
local found = workspace:FindFirstChild("Brick")
if found then
found.Name = "Foo"
end

findFirstChild
Déprécié

FindFirstChildOfClass
Écrire en parallèle
Instance:FindFirstChildOfClass(className:string):Instance?
Paramètres
className:string
Retours
Échantillons de code
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
Écrire en parallèle
Accès à la simulation
Instance:FindFirstChildWhichIsA(
className:string, recursive:boolean
Paramètres
className:string
recursive:boolean
Valeur par défaut : false
Retours

FindFirstDescendant
Écrire en parallèle
Instance:FindFirstDescendant(name:string):Instance?
Paramètres
name:string
Retours

GetActor
Écrire en parallèle
Instance:GetActor():Actor?
Retours

GetAttribute
Écrire en parallèle
Accès à la simulation
Instance:GetAttribute(attribute:string):Variant
Paramètres
attribute:string
Retours
Variant

GetAttributeChangedSignal
Instance:GetAttributeChangedSignal(attribute:string):RBXScriptSignal
Paramètres
attribute:string

GetAttributes
Écrire en parallèle
Accès à la simulation
Instance:GetAttributes():Dictionary
Retours

GetChildren
Écrire en parallèle
Accès à la simulation
Instance:GetChildren():Instances
Retours
Instances
Échantillons de code
Instance:GetChildren
local children = workspace:GetChildren()
for i = 1, #children do
print(i, children[i].Name)
end

getChildren
Déprécié

GetDebugId
Non navigable
Sécurité des plugins
Instance:GetDebugId(scopeLength:number):string
Paramètres
scopeLength:number
Valeur par défaut : 4
Retours
Échantillons de code
Instance:GetDebugId
print(workspace:GetDebugId()) --> 39FA_12
print(workspace:GetDebugId(10)) --> 39FA2FEF4D_12
print(workspace:GetDebugId(math.huge)) --> 12

GetDescendants
Écrire en parallèle
Accès à la simulation
Instance:GetDescendants():Instances
Retours
Instances
Échantillons de code
Instance:GetDescendants
local descendants = workspace:GetDescendants()
-- Parcourir tous les descendants de l'espace de travail. Si un
-- BasePart est trouvé, le code change la couleur de cette pièce en vert
for _, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end

GetFullName
Écrire en parallèle
Accès à la simulation
Instance:GetFullName():string
Retours
Échantillons de code
Instance:GetFullName
-- Créer une hiérarchie simple
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 = "Bonjour, le monde"
print(fire:GetFullName()) --> Workspace.Model.Bonjour, le monde.Fire
Instance:GetFullName Implémentation Lua
local function getFullName(object)
local result = object.Name
object = object.Parent
while object and object ~= game do
-- Préfixer le nom du parent
result = object.Name .. "." .. result
-- Monter dans la hiérarchie
object = object.Parent
end
return result
end
print(getFullName(workspace.Camera)) --> Workspace.Camera

GetStyled
Instance:GetStyled(
name:string, selector:string?
):Variant
Paramètres
name:string
selector:string?
Retours
Variant

GetStyledPropertyChangedSignal
Instance:GetStyledPropertyChangedSignal(property:string):RBXScriptSignal
Paramètres
property:string

GetTags
Écrire en parallèle
Accès à la simulation
Instance:GetTags():{any}
Retours

HasTag
Écrire en parallèle
Accès à la simulation
Instance:HasTag(tag:string):boolean
Paramètres
tag:string
Retours

IsAncestorOf
Écrire en parallèle
Accès à la simulation
Instance:IsAncestorOf(descendant:Instance):boolean
Paramètres
descendant:Instance
Retours
Échantillons de code
Instance:IsAncestorOf()
local Workspace = game:GetService("Workspace")
local spawnLocation = Workspace.SpawnLocation
local decal = spawnLocation.Decal
-- Ces déclarations sont vraies
print(Workspace:IsAncestorOf(spawnLocation))
print(Workspace:IsAncestorOf(decal))
print(spawnLocation:IsAncestorOf(decal))
-- Ces déclarations sont fausses
print(spawnLocation:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(Workspace))
print(decal:IsAncestorOf(spawnLocation))

IsDescendantOf
Écrire en parallèle
Accès à la simulation
Instance:IsDescendantOf(ancestor:Instance):boolean
Paramètres
ancestor:Instance
Retours
Échantillons de code
Instance:IsDescendantOf
local part = Instance.new("Part")
print(part:IsDescendantOf(game))
--> faux
part.Parent = workspace
print(part:IsDescendantOf(game))
--> vrai
part.Parent = game
print(part:IsDescendantOf(game))
--> vrai

isDescendantOf
Déprécié

IsPropertyModified
Accès à la simulation
Instance:IsPropertyModified(property:string):boolean
Paramètres
property:string
Retours

QueryDescendants
Accès à la simulation
Instance:QueryDescendants(selector:string):Instances
Paramètres
selector:string
Retours
Instances

Remove
Déprécié

remove
Déprécié

RemoveTag
Instance:RemoveTag(tag:string):()
Paramètres
tag:string
Retours
()

ResetPropertyToDefault
Instance:ResetPropertyToDefault(property:string):()
Paramètres
property:string
Retours
()

SetAttribute
Accès à la simulation
Instance:SetAttribute(
attribute:string, value:Variant
):()
Paramètres
attribute:string
value:Variant
Retours
()

WaitForChild
Peut augmenter
Instance:WaitForChild(
childName:string, timeOut:number
Paramètres
childName:string
timeOut:number
Retours
Échantillons de code
Instance:WaitForChild
local part = workspace:WaitForChild("Part")
print(part.Name .. " a été ajoutée au Workspace")

Événements
AncestryChanged
Instance.AncestryChanged(
child:Instance, parent:Instance
Paramètres
child:Instance
parent:Instance
Échantillons de code
Instance.AncestryChanged
local Workspace = game:GetService("Workspace")
local redPart = script.Parent.RedPart
local bluePart = script.Parent.BluePart
local changingPart = script.Parent.ChangingPart
-- Changez la couleur de changingPart en fonction de son 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} est maintenant parenté à {parent.Name}`)
end
changingPart.AncestryChanged:Connect(onAncestryChanged)
-- Définissez la propriété Parent de changingPart sur différentes instances au fil du temps
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
Paramètres
attribute:string

ChildAdded
Instance.ChildAdded(child:Instance):RBXScriptSignal
Paramètres
child:Instance
Échantillons de code
Instance.ChildAdded
local function onChildAdded(instance)
print(instance.Name .. " ajouté à l'espace de travail")
end
workspace.ChildAdded:Connect(onChildAdded)
local part = Instance.new("Part")
part.Parent = workspace --> Partie ajoutée à l'espace de travail

childAdded
Déprécié

ChildRemoved
Instance.ChildRemoved(child:Instance):RBXScriptSignal
Paramètres
child:Instance
Échantillons de code
Instance.ChildRemoved
local function onChildRemoved(instance)
print(instance.Name .. " retiré du 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
Paramètres
descendant:Instance
Échantillons de code
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
Paramètres
descendant:Instance
Échantillons de code
Instance.DescendantRemoving
workspace.DescendantRemoving:Connect(function(descendant)
print(descendant.Name .. " est actuellement parenté à " .. tostring(descendant.Parent))
end)
local part = Instance.new("Part")
part.Parent = workspace
part.Parent = nil
--> La pièce est actuellement parentée au Workspace
print(part.Parent)
--> nil

Destroying
Instance.Destroying():RBXScriptSignal
Échantillons de code
Utilisation de l'événement de destruction (signaux immédiats)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("Avant de se bloquer :", part:GetFullName(), #part:GetChildren())
task.wait()
print("Après s'être bloqué :", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
part:Destroy()
Utilisation de l'événement Destroying (signaux différés)
local part = Instance.new("Part", workspace)
local function onPartDestroying()
print("Dans le signal :", part:GetFullName(), #part:GetChildren())
end
part.Destroying:Connect(onPartDestroying)
print("Avant la destruction :", part:GetFullName(), #part:GetChildren())
part:Destroy()
print("Après la destruction :", part:GetFullName(), #part:GetChildren())

StyledPropertiesChanged
Instance.StyledPropertiesChanged():RBXScriptSignal

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.