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

Is it possible to negate a part through script?

Asked by 2 years ago

So I am new to scripting, I have little experience and was wondering if there was any way to negate a part in a script as you are able to do so in the model tab. If so, is there anything else for union? Please let me know and thank you.

0
I found a thread similar to your question that may be useful. https://devforum.roblox.com/t/negating-tool-through-scripts/564323 xInfinityBear 1777 — 2y
0
Why would you do this? Kingu_Criminal 205 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

You can use BasePart:SubtractAsync(). It is basically the opposite of BasePart:UnionAsync().

local PartA = workspace.PartA
local PartB = workspace.PartB

--imagine PartB is within PartA
local success, negatedPart = pcall(function()
    return PartA:SubtractAsync({PartB})
end)

if success and negatedPart then -- if PartB was within PartA and it was a success on negating the part
    print("PartA has been negated through a script! :D")
end
0
when I put this, the output showed that it worked because it printed the string.. Although when i look in game, nothing visually changed in neither the client or the server. Afterineta 4 — 2y
Ad

Answer this question