Ad
Log in to vote
0

Is it possible to Union/Negate through scripts?

Asked by 11 days ago

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

3 answers

Log in to vote
1
Answered by 10 days ago

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.

Ad
Log in to vote
2
Answered by
sO_Ov 275 Moderation Voter
11 days ago

Yeah, you can use BasePart:UnionAsync

Log in to vote
0
Answered by 9 days ago

You forgot BasePart:SubtractAsync()

Answer this question