Having some trouble with getting UnionAsync to work

Hello, I have been trying to add destruction physics to my game, so i created a tool that creates negative parts when hitting a part, and them unions them together, however, this is not working. There is the error message “Something went wrong. CSG returned error code -6. Please file a bug report, preferably with a file containing the problematic object(s).”

I also tried it with normal parts rather than negative parts, but it does nothing and there is no error message, how can i fix this?

local destroyPart = Instance.new("NegateOperation")
			destroyPart.Anchored = true
			destroyPart.Parent = game.Workspace
			destroyPart.Position = script.Parent.Handle.Attachment.Position -- This is the position of the item used to destroy things
			destroyPart.Transparency = 1
			destroyPart.CanCollide = false
			destroyPart.Size = Vector3.new(1,1,1)
			part:UnionAsync({destroyPart})

The problem with CSG is that it cannot create complicated objects. I don’t believe you’ll ever find a way to get this reliably working.

However, you can try enabling CSG 3 in the beta features section of studio.

1 Like

That’s unfortunate, however thank you for the advice!

Thanks for reporting the bug. We’ll look into the issue.

@62bumperbrush
The “NegateOpertaion” part you created is an operation without any part information and that’s why CSG is failing. You can use SubtractAsyn instead of UnionAsyn, and subtract a part from another part.

local destroyPart = Instance.new("Part")
local existingPart = game.Workspace.existingPart
destroyPart.Anchored = true
destroyPart.Parent = game.Workspace
destroyPart.Position = existingPart.Position
destroyPart.Transparency = 1
destroyPart.CanCollide = false
destroyPart.Size = Vector3.new(1,1,1)
newUnion = existingPart:SubtractAsync({destroyPart})
newUnion.Parent = game.Workspace

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.