Hello Developers!
I have seen something in coding which is BasePart:SubtractAsync()
. Now in my understandings, BasePart:SubtractAsync()
is simply a way to create unions ingame, imagine it like slicing a piece of bread ingame without using two seperate parts. The issue however is that I am entirely new to it and I'm curious to how to set it up
To use SubtractAsync()
, the basic parameters are:
-- an array is a table in which the key is a number and the value is any, for example {1, 2, "hi"} or {[1] = 1, [2] = 2, [3] = "hi"} local ArrayOfPartsToSubtract = {} -- inside this array should be BaseParts (Parts, Terrains) local NewUnion = OriginalPart:SubtractAsync(ArrayOfPartsToSubtract)
Take note of these things:
The event takes a table as an input (the block(s) that will act as the NegativePart), so put any parts in a table.
If it is successful in creating a union, then it will not delete the blocks created to make the union, so you will have to delete those yourself. Also make sure to parent the union to the workspace.
There are two other parameters you can use (CollisionFidelity
and RenderFidelity
. Usually you won't use these parameters as the default settings work fine, but if you want to learn more about them, then the Roblox Creator Documentation explains them well.
I don't know what you exactly mean with "without using two separate parts". Making unions is impossible without a main part and a NegativePart. SubtractAsync()
is basically a way to make unions in a script with a main part and different parts to subtract its volume with.