CSG Error Code -6

Hello. I am trying to union a NegateOperation and a Part. They both appear when the game runs. However, I get this error: Something went wrong. CSG returned error code -6. Please file a bug report, preferably with a file containing the problematic object(s). I believe this to be my fault and not Studio’s.

Here’s my code:

local wall = Instance.new("Part")
wall.Name = "Wall"
wall.Anchored = true
wall.Position = base.Position
wall.Size = Vector3.new(base.Size.X, WALL_HEIGHT, base.Size.Z)
wall.Material = WALL_MATERIAL
wall.Color = WALL_COLOR
wall.Parent = workspace

local wallNegate = Instance.new("NegateOperation")
wallNegate.Anchored = true
wallNegate.CanCollide = false
wallNegate.Transparency = 1
wallNegate.Position = wall.Position
wallNegate.Size = Vector3.new(wall.Size.X - 3, wall.Size.Y, wall.Size.Z - 3)
wallNegate.Parent = workspace

wall:UnionAsync({wallNegate})

(base is just a platform for scale)

Thanks in advance.

1 Like

If you have -6 code, you can’t do anything, you have to re-create the part that you want to union, I already had this problem and had to re-create the part to continue to union it.

1 Like

That may work. However I need the part I am unioning with the NegateOperation to be dynamic. I need to be able to do this via code. If you have a way to do this via code, I would be very grateful.

Edit: I tested it with a part that was created in the workspace. It worked fine, same properties. I’m not sure what is going on.

I fixed it! Here’s my code:

local wall = Instance.new("Part")
wall.Name = "Wall"
wall.Anchored = true
wall.Size = Vector3.new(base.Size.X, WALL_HEIGHT, base.Size.Z)
wall.Position = base.Position + Vector3.new(0, (wall.Size.Y / 2) + (base.Size.Y / 2), 0)
wall.Material = WALL_MATERIAL
wall.Color = WALL_COLOR
wall.Parent = workspace

local wallNegate = Instance.new("Part")
wallNegate.Anchored = true
wallNegate.CanCollide = false
wallNegate.Transparency = 1
wallNegate.Position = wall.Position
wallNegate.Size = Vector3.new(wall.Size.X - 3, wall.Size.Y, wall.Size.Z - 3)
wallNegate.Parent = workspace

local success, newSubt = pcall(function()
	return wall:SubtractAsync({wallNegate})	
end)
if success and newSubt then
	newSubt.Position = wall.Position
	newSubt.Parent = workspace
else
	print("Wall failed to generate")
end
wallNegate:Destroy()
wall:Destroy()

I think using SubtractionAsync() worked. Not sure if it is possible to do it with UnionAsync().

2 Likes

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