(Accidently over wrote this)
Some reason when using Subtract Async it creates invisible unions/parts?
local function GetTouchingParts(part) -- gets touching parts, even not can collide
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
local function CutPart(Pos, Orientation)
local Invis = game.Workspace.Ignore.Invisible -- move the invisible part in place
Invis.Position = Pos
Invis.Orientation = Orientation
local Touching = GetTouchingParts(game.Workspace.Ignore.Invisible) -- get touching
for i,v in pairs(Touching) do
if v.Parent.Name == "Cutable" then -- can be cut (In a folder called "Cutable")
local Cut1 = Instance.new("Part") -- create first part for Subtract
Cut1.Anchored = true
Cut1.CanCollide = false
Cut1.Transparency = .7
Cut1.Color = Color3.fromRGB(255,0,0)
Cut1.Size = Vector3.new(v.Size.X*2, v.Size.Y*2, v.Size.Z*2) -- make it bigger just incase
Cut1.CFrame = (Invis.CFrame + Invis.CFrame.UpVector*(Cut1.Size/2)) -- move it above the Invisible Part
Cut1.Parent = game.Workspace.Ignore
local Cut2 = Cut1:Clone() -- create second part for Subtract
Cut2.Color = Color3.fromRGB(0,255,0)
Cut2.CFrame = (Invis.CFrame + Invis.CFrame.UpVector*-(Cut2.Size/2)) -- move it below the Invisible Part
Cut2.Parent = game.Workspace.Ignore
local union1 = v:SubtractAsync({Cut1}) -- subtract first part
union1.Anchored = false
union1.Parent = v.Parent
union1.Name = "union1"
local union2 = v:SubtractAsync({Cut2}) -- subtract second part
union2.Anchored = false
union2.Parent = v.Parent
union2.Transparency = 0
union2.Name = "union2"
v:Destroy() -- delete original
game:GetService("Debris"):AddItem(Cut1, 1)
game:GetService("Debris"):AddItem(Cut2, 1)
end
end
end
Add to call it using the code:
CutPart(Vector3.new( -11.0081692, 9.77158928, -73.8000031), Vector3.new(0,0,45))
Is there any possibility i am corrupting the unions on creation?