autofarm zombies
game.Players.LocalPlayer.CharacterAdded:Connect(function() task.wait(1) spawn(function() while task.wait() do pcall(function() if not game.Players.LocalPlayer.Character:FindFirstChild("Machete") then game.Players.LocalPlayer.Character.Humanoid:EquipTool(game.Players.LocalPlayer.Backpack.Machete) else game.Players.LocalPlayer.Character.Machete:Activate() end end) end end) while true do task.wait() pcall(function() local zombies = {} local distances = {} local hrp = game.Players.LocalPlayer.Character.HumanoidRootPart local humanoid = game.Players.LocalPlayer.Character.Humanoid for i, v in pairs(workspace:GetChildren()) do if v:FindFirstChild("Reward") and v:FindFirstChild("Move") then if v:FindFirstChild("HumanoidRootPart") then table.insert(zombies, v) end end end for i, v in pairs(zombies) do table.insert(distances, {(hrp.Position - v.HumanoidRootPart.Position).Magnitude, v}) end repeat task.wait() for i, v in pairs(distances) do if distances[i + 1] then print(v[i]) --print(i) debug if v[1] > distances[i + 1][1] then table.remove(distances, i) else table.remove(distances, i + 1) end end end until not distances[2] local zombie = distances[1][2] print(zombie, distances[1][1]) --debug local pathfinder = game:GetService("PathfindingService") local pathy = pathfinder:CreatePath() pathy:ComputeAsync(hrp.Position, zombie.HumanoidRootPart.Position) if pathy.Status == Enum.PathStatus.Success then for i, v in pairs(pathy:GetWaypoints()) do local pos = v.Position humanoid:MoveTo(pos) humanoid.MoveToFinished:Wait() end else hrp.CFrame = hrp.CFrame + Vector3.new(0, 100, 0) task.wait(1) if pathy.Status == Enum.PathStatus.Success then for i, v in pairs(pathy:GetWaypoints()) do local pos = v.Position humanoid:MoveTo(pos) humanoid.MoveToFinished:Wait() end else warn("Pathfinding unsuccessful, waiting...") task.wait(2) end end end) end end) game.Players.LocalPlayer.Character.Head:Destroy()