I am trying to make a tool that slices things in half but i get an error “attempt to index nil with ‘SubtractAsync’”
local script
local player = game.Players.LocalPlayer
local backpack = player:WaitForChild("Backpack")
local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Parent = backpack
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Parent then
local part1 = mouse.Target
local part2 = part1:Clone()
wait()
local neg1 = Instance.new("Part")
local neg2 = Instance.new("Part")
neg1.Position = Vector3.new(part1.Position.X,part1.Position.Y + part1.Size.Y / 2,part1.Position.Z)
neg2.Position = Vector3.new(part2.Position.X,part2.Position.Y - part2.Size.Y / 2,part2.Position.Z)
neg1.Size = Vector3.new(part1.Size.X,part1.Size.Y + part1.Position.Y / 2,part1.Size.Z)
neg2.Size = Vector3.new(part2.Size.X,part2.Size.Y - part2.Position.Y / 2,part2.Size.Z)
wait()
game.ReplicatedStorage.SlashEvent:FireServer(player,neg1,neg2,part1,part2)
end
end)
end)
server script
game.ReplicatedStorage.SlashEvent.OnServerEvent:Connect(function(player,neg1,neg2,part1,part2)
local n1 = {neg1}
local n2 = {neg2}
local newUnion1 = part1:SubtractAsync(n1)
local newUnion2 = part2:SubtractAsync(n2)
end)