Classe de moteur
Selection
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Propriétés
Méthodes
Add(instancesToAdd: Instances):() |
Get():Instances |
Remove(instancesToRemove: Instances):() |
Set(selection: Instances):() |
Événements
Échantillons de code
Sélection
local Selection = game:GetService("Selection")
for _, object in pairs(Selection:Get()) do
if object:IsA("BasePart") then
object.CFrame = object.CFrame * CFrame.Angles(0, math.pi / 2, 0)
end
endRéférence API
Propriétés
Méthodes
Add
Selection:Add(instancesToAdd:Instances):()
Paramètres
instancesToAdd:Instances |
Retours
()
Get
Selection:Get():Instances
Retours
Instances
Échantillons de code
Sélection
local Selection = game:GetService("Selection")
for _, object in pairs(Selection:Get()) do
if object:IsA("BasePart") then
object.CFrame = object.CFrame * CFrame.Angles(0, math.pi / 2, 0)
end
endSélection.SélectionChangée
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("La sélection contient " .. #selection:Get() .. " éléments.")
end)Remove
Selection:Remove(instancesToRemove:Instances):()
Paramètres
instancesToRemove:Instances |
Retours
()
Set
Selection:Set(selection:Instances):()
Paramètres
selection:Instances |
Retours
()
Échantillons de code
Ensemble de Sélection
local Selection = game:GetService("Selection")
local newSelection = {}
for _, object in pairs(workspace:GetDescendants()) do
if object:IsA("BasePart") and object.BrickColor == BrickColor.new("Bright red") then
table.insert(newSelection, object)
end
end
Selection:Set(newSelection)Événements
SelectionChanged
Échantillons de code
Sélection.SélectionChangée
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("La sélection contient " .. #selection:Get() .. " éléments.")
end)