0

# Is it possible to Union/Negate through scripts?

It's a silly, yet important question. Is it possible to Union/Negate parts through scripts?

1

I made this sweet little function help you union parts through scripts, they just have to be in a model!

Where you see GetChildren can be changed to GetDescendants if you decide you want to union the entire hierarchy of the Model.

local function UnionModel(Model)
local BaseParts = {}
local PrimaryPart = Model.PrimaryPart or Model:FindFirstChildWhichIsA("BasePart")
for _, BasePart in pairs(Model:GetChildren()) do
if BasePart:IsA("BasePart") and BasePart ~= PrimaryPart then
table.insert(BaseParts, BasePart)
continue
end
end
return PrimaryPart:UnionAsync(BaseParts)
end


@sO_Ov also has posted the DevHub page for it, if you're looking for a more thorough description.

2
sO_Ov 275
11 days ago

Yeah, you can use BasePart:UnionAsync

0

You forgot BasePart:SubtractAsync()