It's a silly, yet important question. Is it possible to Union/Negate parts through scripts?
✓ ANSWER ACCEPTED
Is it possible to Union/Negate through scripts?
3 answers
✓ Accepted answer
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.
Yeah, you can use BasePart:UnionAsync
You forgot BasePart:SubtractAsync()
This discussion is preserved as it was. New answers, comments, and votes are closed.
