學習
引擎類別
Selection
無法建立
服務

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要

方法
Add(instancesToAdd: Instances):()
Get():Instances
Remove(instancesToRemove: Instances):()
Set(selection: Instances):()
繼承成員
範例程式碼
選擇
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
end

API 參考
屬性
SelectionThickness
唯讀
未複製
平行讀取
功能: Basic
Selection.SelectionThickness:number

方法
Add
外掛程式安全性
功能: Basic
Selection:Add(instancesToAdd:Instances):()
參數
instancesToAdd:Instances
返回
()

Get
外掛程式安全性
功能: Basic
Selection:Get():Instances
返回
Instances
範例程式碼
選擇
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
end
Selection.SelectionChanged
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("選取包含 " .. #selection:Get() .. " 項目。")
end)

Remove
外掛程式安全性
功能: Basic
Selection:Remove(instancesToRemove:Instances):()
參數
instancesToRemove:Instances
返回
()

Set
外掛程式安全性
功能: Basic
Selection:Set(selection:Instances):()
參數
selection:Instances
返回
()
範例程式碼
選擇集
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)
設置
local selected = Selection:Get()
table.insert(selected, object)
Selection:Set(selected)

活動
SelectionChanged
功能: Basic
Selection.SelectionChanged():RBXScriptSignal
範例程式碼
Selection.SelectionChanged
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("選取包含 " .. #selection:Get() .. " 項目。")
end)

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。