Selection
概要
プロパティ
コードサンプル
選択
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
endAPIリファレンス
プロパティ
方法
Add
Selection: Add(instances To Add:Instances):()
パラメータ
instancesToAdd:Instances |
戻り値
()
Get
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
endSelection.SelectionChanged
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("選択には " .. #selection:Get() .. " アイテムが含まれています。")
end)Remove
Selection: Remove(instances To Remove:Instances):()
パラメータ
instancesToRemove:Instances |
戻り値
()
Set
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 Selection = game:GetService("Selection")
local object = workspace:WaitForChild("Part")
-- 選択されたオブジェクトを取得します
local selected = Selection:Get()
table.insert(selected, object)
-- 選択されたオブジェクトを設定します
Selection:Set(selected)イベント
Selection Changed
コードサンプル
Selection.SelectionChanged
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("選択には " .. #selection:Get() .. " アイテムが含まれています。")
end)