We use cookies on this site to enhance your user experience

Basic In-Game Subtract Operation

Basic In-Game Subtract Operation

Sep 07 2018, 12:47 PM PST

This example assumes there are three parts named Part1, Part2, and Part3 in the Workspace. It creates a union by subtracting Part2 and Part3 from Part1, destroys the original parts, and inserts the resulting UnionOperation.

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

-- Perform subtract operation
local newUnion = part:SubtractAsync(otherParts)

-- Destroy source parts
part:Destroy()
for _, otherPart in pairs(otherParts)
	otherPart:Destroy()
end

-- Insert new union into workspace
newUnion.Parent = workspace