Negating Tool through scripts!

Im wondering is it possible to negative a part to another part through code?

Any help loved!

2 Likes

I don’t think there is a way to do it because Negate is not a member of Part and it doesn’t have any properties are anything. There is no way to negate 2 parts together using a script since there is no way to call it. I think you will need to create a hardcore plugin to do that and probably someone in the future would invent something good like that.

But if you want to negate faster you could just use the Ctrl + Shift + G.

I think there is a way, I found this im just having a hard time understanding it.

1 Like

That also has a relation with Unions, but the function that negates parts is :SubtractAsync(), strangely enough, this method has no documentation. What might be also possible to do is inserting a negative part using Instance.new()

1 Like

That makes the part go together with unions, it would work like this:

UNION

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

-- Place parts together 

local newUnion = part:UnionAsync(otherParts)

NEGATE

newUnion:SubstractAsync()

I don’t use scripts to negate and union parts as theres no point, you could just do it manually.

2 Likes

Im trying to make it so if my cannonball hits a wall it can make a hole in the wall

1 Like

In that case then you would make a separate part called “Hole” and then add another part and name it “Wall”. Then use a touched event to detect whether the cannonball has hit the wall and if it did then make the Wall invisible and the Hole visible.

If you want it smooth though then you will need to mess with some physics.

local part = script.Parent
local otherParts = {workspace.CannonHoles.Union}



part.Touched:Connect(function(part)
	if part.Name == "CannonBall" then
		
		wait(0.1)
		local negate = part:SubtractAsync(otherParts)
		part:Destroy()
		print("hole added")
	end
end)

This is my current code, no errors, but its not negating, I think the problem is that the Negate block is not on the part, just wondering how I move the blocks position, to the part?
https://gyazo.com/670755192b672e48fcf330397f99ec49

You will need to use the :UnionAsync function to union the part then negate it using the :SubstractAsync

So I need to union the HOLE part to the WALL part first then negate the to?

I mean negate the Wall and the part then union them using the functions.

The DevHub has all the information you need - make sure you always check the DevHub for information first before making a support topic.

Here is the page: Solid Modeling | Documentation - Roblox Creator Hub

4 Likes

https://www.youtube.com/watch?v=Rj-_cjGfCCY&list=PLuEQ5BB-Z1PJ4JIDXpttxuvCzJMeIqzMi&index=20 this tutorial might help