Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to Union/Negate through scripts?

Asked by 3 years ago

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

3 answers

Log in to vote
2
Answered by 3 years 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
174gb 290 Moderation Voter
3 years ago

Yeah, you can use BasePart:UnionAsync

Log in to vote
0
Answered by 3 years ago

You forgot BasePart:SubtractAsync()

Answer this question