I’m trying to make a tool that cuts thing, but the second time I cut something I get this.
Players.xXRed_VoidXx.Backpack.Katana.Cut:20: attempt to index nil with ‘Anchored’
The SubtractAsync is actually nil, I managed to print it. I can cut any part or union once, but if I cut the same thing twice it errors.
(sorry for the super scuffed katana, im not a good modeler)
The reason I went to the big block is because it had already been cut, not even by the katana, to show that it still errors.
Code:
local touch = true
script.Parent.Blade.Touched:Connect(function(part)
if touch == true then
touch = false
part.Anchored = true
local paren = part.Parent
part.Parent = workspace.PreCuts
local slice = game.ReplicatedStorage.Slice:Clone()
slice:PivotTo(script.Parent.Blade.CFrame)
slice.Parent = workspace.Slices
local double = part:Clone()
double.CFrame = part.CFrame
double.Parent = workspace.PreCuts
local leP = {part, slice.Left}
local left = part:SubtractAsync(leP,Enum.CollisionFidelity.PreciseConvexDecomposition)
local riP = {double, slice.Right}
local right = double:SubtractAsync(riP,Enum.CollisionFidelity.PreciseConvexDecomposition)
workspace.PreCuts:ClearAllChildren()
workspace.Slices:ClearAllChildren()
left.Anchored = false
right.Anchored = false
left.Velocity = part.Velocity
right.Velocity = part.Velocity
left.Parent = paren
right.Parent = paren
part:Destroy()
wait(1)
touch = true
end
end)