Hello everyone, hope y’all having a good day, I’m trying to make a tool for my building game that unions parts and negates and seperates, Everything work except when you are trying to union an negate part with an normal part it doesn’t work and I have no idea how to fix it, I hope someone can help me with this problem. My code:
if Type == "Union" then
local newUnion = TargetPart:UnionAsync(Parts)
newUnion.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
--newUnion.Position = TargetPart.Position
newUnion.UsePartColor = true
local targetPartObj = Instance.new("ObjectValue", newUnion)
targetPartObj.Name = "TargetPartV"
targetPartObj.Value = TargetPart
targetPartObj.Value.Parent = nil
local folder = Instance.new("Folder", newUnion)
folder.Name = "Parts"
for i, v in Parts do
local PartObj = Instance.new("ObjectValue", folder)
PartObj.Name = "UnionPart"
PartObj.Value = v
PartObj.Value.Parent = nil
end
elseif Type == "Negate" then
local NegatePart = game.ServerStorage.NegativeParts[TargetPart.Shape.Name.."NegativePart"]:Clone()
NegatePart.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
NegatePart.Position = TargetPart.Position
NegatePart.Size = TargetPart.Size
NegatePart.Rotation = TargetPart.Rotation
NegatePart.Anchored = true
NegatePart.CanCollide = false
NegatePart.UsePartColor = true
TargetPart:Destroy()
local targetPartObj = Instance.new("ObjectValue", NegatePart)
targetPartObj.Name = "TargetPartV"
targetPartObj.Value = TargetPart
targetPartObj.Value.Parent = nil
if Parts ~= {} then
for i, v in Parts do
local NegatePart2 = game.ServerStorage.NegativeParts[v.Shape.Name.."NegativePart"]:Clone()
NegatePart2.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
NegatePart2.Position = v.Position
NegatePart2.Size = v.Size
NegatePart2.Rotation = v.Rotation
NegatePart2.Anchored = true
NegatePart2.CanCollide = false
NegatePart2.UsePartColor = true
local targetPartObj2 = Instance.new("ObjectValue", NegatePart2)
targetPartObj2.Name = "TargetPartV"
targetPartObj2.Value = TargetPart
targetPartObj2.Value.Parent = nil
end
end
elseif Type == "Seperate" then
if TargetPart:IsA("UnionOperation") then
if TargetPart:FindFirstChild("TargetPartV") then
if TargetPart.TargetPartV.Value ~= nil then
TargetPart.TargetPartV.Value.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
else
-- nothing
end
if TargetPart:FindFirstChild("Parts") then
for i, v in pairs(TargetPart.Parts:GetDescendants()) do
if v:IsA("ObjectValue") then
if v.Value ~= nil then
v.Value.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
end
end
end
TargetPart:Destroy()
end
end
elseif TargetPart:IsA("NegateOperation") then
if TargetPart:FindFirstChild("TargetPartV") then
if TargetPart.TargetPartV.Value ~= nil then
TargetPart.TargetPartV.Value.Parent = workspace.F3XFolder[Player.Name.."'s Folder"]
TargetPart:Destroy()
end
end
end
end