How do I create unions with a script?

You can use

BasePart:UnionAsync(OtherPartTable)

where BasePart is the part you want to union, and the parts in the OtherPartTable are the parts BasePart will union with.

For example:

local part = workspace.Part1
local otherParts = {workspace.Part2, workspace.Part3, workspace.Part4}

local newUnion = part:UnionAsync(otherParts)

Alternatively, if you want to subtract from a part, you can use BasePart:SubtractAsync(OtherPartsTable)

for example:

local part = workspace.Part1
local otherParts = {workspace.Part2, workspace.Part3, workspace.Part4}

local newUnion = part:SubtractAsync(otherParts)

For more information:

UnionAsync API page

SubtractAsync API page

78 Likes