Lớp công cụ
Selection
*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
Thuộc Tính
Phương Pháp
Add(instancesToAdd: Instances):() |
Get():Instances |
Remove(instancesToRemove: Instances):() |
Set(selection: Instances):() |
Sự Kiện
Mẫu mã
Lựa chọn
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
endTài Liệu Tham Khảo API
Thuộc Tính
Phương Pháp
Add
Selection:Add(instancesToAdd:Instances):()
Tham Số
instancesToAdd:Instances |
Lợi Nhuận
()
Get
Selection:Get():Instances
Lợi Nhuận
Instances
Mẫu mã
Lựa chọn
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
endThay đổi lựa chọn.Chọn
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("Lựa chọn chứa " .. #selection:Get() .. " mục.")
end)Remove
Selection:Remove(instancesToRemove:Instances):()
Tham Số
instancesToRemove:Instances |
Lợi Nhuận
()
Set
Selection:Set(selection:Instances):()
Tham Số
selection:Instances |
Lợi Nhuận
()
Mẫu mã
Tập hợp lựa chọn
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)Sự Kiện
SelectionChanged
Mẫu mã
Thay đổi lựa chọn.Chọn
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("Lựa chọn chứa " .. #selection:Get() .. " mục.")
end)