How do I create unions with a script?

So I have a part, which I want people to be able to put windows on, similar to bloxburg. This way would make a union where the window should be and place the window. I was wondering if bloxburg creates unions because that is impossible, so I want to know how they do that.

14 Likes

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

74 Likes

Is there a way to Un Union with a script?