I will add videos and screenshots when I get home
please read whole post
I’m making a katana tool that slices things in half, but it has a fatal error.
Explanation on how it slices things
It’s fairly simple, just clones a model in replicated storage with two giant negative parts, clones the part that’s going to be sliced, then the left negative part slices the original part, and the right negative part slices the cloned part.
It works flawlessly the first time I cut a part, but after that I get this error:
Players.xXRed_VoidXx.Backpack.Katana.Cut:37: attempt to index nil with ‘Parent’
This is the line that sets the left slice into the workspace.
Another absolutely mind boggling thing is that I can slice as many parts, but I cant cut a part more than once. And yes, it can slice any union.
A short summary(ish):
After cutting a part, the slices are just fine.
After cutting the slices, the unions(slices) are nil, and somehow don’t exist
The code: (the reason so much is commented is because I’m trying to experiment and narrow the problem down)
local touch = true
script.Parent.Blade.Touched:Connect(function(part1)
if touch == true then
touch = false
part1.Anchored = true
local par = part1.Parent
--part1:Destroy()
part1.CanTouch = false
part1.Transparency = 0.9
print(par)
local slice = game.ReplicatedStorage.Slice:Clone()
slice:PivotTo(part1.CFrame)
slice.Parent = workspace.Slices
wait(1)
--local double = part1:Clone()
--double.CFrame = part1.CFrame
--double.Parent = part1.Parent
local leP = {part1, slice.Left}
--print(part1)
--print(slice.Left)
--local riP = {double, slice.Right}
local left = part1:SubtractAsync(leP,Enum.CollisionFidelity.PreciseConvexDecomposition)
--left.Name = "WallLeft"
--print(left)
--local right = double:SubtractAsync(riP,Enum.CollisionFidelity.PreciseConvexDecomposition)
--workspace.Slices:ClearAllChildren()
--double:Destroy()
--left.Anchored = false
--right.Anchored = false
--left.Velocity = part1.Velocity
--right.Velocity = part1.Velocity
--left:Remove()
--print(left.Parent)
print(left)
wait(1)
left.Parent = par
left.Transparency = 0
--right.Parent = workspace
wait(1)
touch = true
end
end)
The problem is the left.Parent.
Somehow I even got an error just printing left.
Sorry, it’s a little hard to explain on a crappy computer that doesn’t have obs.
Also, a question, why does subtractAsync delete the OTHER half of the part???
I literally deleted the right block, and the LEFT block deletes the half of the part that ISNT IN THE NEGATIVE BLOCK.
edit: I just learned that a part that has been cut NOT by the katana, still gets the error if I cut it with the katana. Maybe I can’t SubtractAsync a part more than once?