The title says it all I need to select only unions using the command bar.
Ive looked on youtube but i cant find anything and i have no idea how to select things using a script.
The title says it all I need to select only unions using the command bar.
Ive looked on youtube but i cant find anything and i have no idea how to select things using a script.
--assume this is going through a model with all the different parts on roblox
for _, part in pairs(model:GetChildren()) do
if part:IsA("Union") then
print("its a union")
end
end
Documentation:
https://developer.roblox.com/en-us/api-reference/function/Instance/IsA
But that doesnt select the union i already know how to make a for loop to loop through the entire workspace to delete all unions (Thats the reason im asking this is to clean up lag) but i need to know how to selecting what im trying to do is select all the unions and convert them into a mesh.
local union = workspace:FindFirstChildOfClass("UnionOperation")
“FindFirstChild”/“FindFirstChildOfClass”/“FindFirstChildWhichIsA” will all fetch the first instance which matches the argument passed to the function.
what?
then what do you want to do
Select the union? It has the blue box around it meaning its selected thats what i want to do but for all the unions without going through all of them.
I mean what do you want to do with the unions after you select them all
local Selection = game:GetService("Selection")
local selected = Selection:Get()
for _, part in pairs(model:GetChildren()) do
if part:IsA("Union") then
table.insert(selected, part)
end
end
Selection:Set(selected)
Comes up with this error
local Selection = game:GetService("Selection")
local unions = {}
for _, part in pairs(model:GetChildren()) do
if part:IsA("Union") then
table.insert(unions, part)
end
end
Selection:Set(unions):3: attempt to index nil with 'GetChildren'
local Selection = game:GetService("Selection")
local selected = Selection:Get()
for _, part in pairs(workspace:GetChildren()) do
if part:IsA("Union") then
table.insert(selected, part)
end
end
Selection:Set(selected)
Nvm that was the error from the other script but it still wont work?
I fixed it! You just needed to change the “Union” to “UnionOperation”.