Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote

How to set up BasePart:SubtractAsync()?

Asked by 1 year ago

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

1 answer

Log in to vote
Answered by
Jac_00b 157
1 year ago
Edited by T3_MasterGamer 1 year ago

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:

  1. The event takes a table as an input (the block(s) that will act as the NegativePart), so put any parts in a table.

  2. 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.

  3. 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.

Alright then, also, when you I mean in the sentence: "imagine it like slicing a piece of bread ingame without using two seperate parts." is that I don't want to create two seperate parts which are pretty much just identical to the bread and script it so the other half of the clone disappears or move slowly (or fast if I wanted that) to simulate it being the entire bread becoming cut imnotaguest1121 362 — 1y

Answer this question