PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

UnionAsync

This is a server-only function that uses CSG to combine the geometry of the calling BasePart with a table of other BasePart|BaseParts. It returns a parentless UnionOperation named Union with the following specs:

  • The faces of the returned UnionOperation inherit the colors of the original parts’ faces.
  • The PartOperation/UsePartColor|UsePartColor property will be false.
  • The PartOperation/CollisionFidelity|CollisionFidelity will match the provided enum (or default).
  • The returned UnionOperation inherits the following properties from the part that this function was called from: BasePart/Color|Color, BasePart/Material|Material, BasePart/Reflectance|Reflectance, BasePart/Transparency|Transparency, BasePart/Anchored|Anchored, BasePart/CanCollide|CanCollide, BasePart/Elasticity|Elasticity, BasePart/Friction|Friction, and BasePart/CustomPhysicalProperties|CustomPhysicalProperties.

See the Articles/in game solid modeling|In-Game Solid Modeling article for more information.

Potential Errors

This function raises an error under the following conditions:

  • When called by the client (this cannot be called by a LocalScript).
  • If any of the objects involved are not supported by CSG (only BasePart|BaseParts are supported, not Terrain or meshes).
  • If the result could not be computed with less than 5000 triangles.
  • Some other CSG problem occurred while attempting to union.

Parameters

Name Type Default Description

The parts being unioned

Default
Automatic

Returns

Return Type Summary

The resulting UnionOperation


Code Samples


Basic In-Game Union Operation

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

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

-- Perform union operation
local newUnion = part:UnionAsync(otherParts)

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

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