学习
引擎类
Selection
无法创建
服务

*此内容使用人工智能(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
选择.选择已更改
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)

活动
SelectionChanged
功能: Basic
Selection.SelectionChanged():RBXScriptSignal
代码示例
选择.选择已更改
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("选择包含 " .. #selection:Get() .. " 项目.")
end)

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。