Advertisement
RandomMagics

Outbreak Tycoon

Feb 26th, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. ---legit Zombies' Farm---
  2. game.Players.LocalPlayer.CharacterAdded:Connect(function()
  3. task.wait(1)
  4. spawn(function()
  5. while task.wait() do
  6. pcall(function()
  7. if not game.Players.LocalPlayer.Character:FindFirstChild("Machete") then
  8. game.Players.LocalPlayer.Character.Humanoid:EquipTool(game.Players.LocalPlayer.Backpack.Machete)
  9. else
  10. game.Players.LocalPlayer.Character.Machete:Activate()
  11. end
  12. end)
  13. end
  14. end)
  15. while true do
  16. task.wait()
  17. pcall(function()
  18. local zombies = {}
  19. local distances = {}
  20. local hrp = game.Players.LocalPlayer.Character.HumanoidRootPart
  21. local humanoid = game.Players.LocalPlayer.Character.Humanoid
  22. for i, v in pairs(workspace:GetChildren()) do
  23. if v:FindFirstChild("Reward") and v:FindFirstChild("Move") then
  24. if v:FindFirstChild("HumanoidRootPart") then
  25. table.insert(zombies, v)
  26. end
  27. end
  28. end
  29. for i, v in pairs(zombies) do
  30. table.insert(distances, {(hrp.Position - v.HumanoidRootPart.Position).Magnitude, v})
  31. end
  32. repeat
  33. task.wait()
  34. for i, v in pairs(distances) do
  35. if distances[i + 1] then
  36. print(v[i])
  37. --print(i) debug
  38. if v[1] > distances[i + 1][1] then
  39. table.remove(distances, i)
  40. else
  41. table.remove(distances, i + 1)
  42. end
  43. end
  44. end
  45. until not distances[2]
  46. local zombie = distances[1][2]
  47. print(zombie, distances[1][1]) --debug
  48. local pathfinder = game:GetService("PathfindingService")
  49. local pathy = pathfinder:CreatePath()
  50. pathy:ComputeAsync(hrp.Position, zombie.HumanoidRootPart.Position)
  51.  
  52. if pathy.Status == Enum.PathStatus.Success then
  53. for i, v in pairs(pathy:GetWaypoints()) do
  54. local pos = v.Position
  55. humanoid:MoveTo(pos)
  56. humanoid.MoveToFinished:Wait()
  57. end
  58. else
  59. hrp.CFrame = hrp.CFrame + Vector3.new(0, 100, 0)
  60. task.wait(1)
  61. if pathy.Status == Enum.PathStatus.Success then
  62. for i, v in pairs(pathy:GetWaypoints()) do
  63. local pos = v.Position
  64. humanoid:MoveTo(pos)
  65. humanoid.MoveToFinished:Wait()
  66. end
  67. else
  68. warn("Pathfinding unsuccessful, waiting...")
  69. task.wait(2)
  70. end
  71. end
  72. end)
  73. end
  74. end)
  75. game.Players.LocalPlayer.Character.Head:Destroy()
  76.  
  77. -----------------------------------------------------------------------------------------
  78. ---Mission and Level Farm---
  79.  
  80. game.Players.LocalPlayer.CharacterAdded:Connect(function()
  81. task.wait(3)
  82. spawn(function()
  83. while task.wait() do
  84. pcall(function()
  85. if not game.Players.LocalPlayer.Character:FindFirstChild("Machete") then
  86. game.Players.LocalPlayer.Character.Humanoid:EquipTool(game.Players.LocalPlayer.Backpack.Machete)
  87. else
  88. game.Players.LocalPlayer.Character.Machete:Activate()
  89. end
  90. end)
  91. end
  92. end)
  93. while true do
  94. task.wait()
  95. pcall(function()
  96. local zombies = {}
  97. local distances = {}
  98. local hrp = game.Players.LocalPlayer.Character.HumanoidRootPart
  99. local humanoid = game.Players.LocalPlayer.Character.Humanoid
  100. if game:GetService("Players").LocalPlayer.Quest.Num.Value == 0 then
  101. hrp.CFrame = game:GetService("Workspace").Quests["Level 1 Quest"].Quest.ClickPart.CFrame
  102. task.wait(0.1)
  103. fireproximityprompt(game:GetService("Workspace").Quests["Level 1 Quest"].Quest.ClickPart.ProximityPrompt)
  104. task.wait(0.1)
  105. game:GetService("Players").LocalPlayer.PlayerGui.QuestTake.Accept.RemoteEvent:FireServer()
  106. end
  107. for i, v in pairs(workspace:GetChildren()) do
  108. if v:FindFirstChild("Reward") and v:FindFirstChild("Move") then
  109. if v:FindFirstChild("HumanoidRootPart") then
  110. table.insert(zombies, v)
  111. end
  112. end
  113. end
  114. for i, v in pairs(zombies) do
  115. if (hrp.Position - v.HumanoidRootPart.Position).Magnitude ~= math.huge then --this is totally necessary, stfu
  116. table.insert(distances, {(hrp.Position - v.HumanoidRootPart.Position).Magnitude, v})
  117. end
  118.  
  119. end
  120. repeat
  121. task.wait()
  122. for i, v in pairs(distances) do
  123. if distances[i + 1] then
  124. print(v[i])
  125. --print(i) debug
  126. if v[1] > distances[i + 1][1] then
  127. table.remove(distances, i)
  128. else
  129. table.remove(distances, i + 1)
  130. end
  131. end
  132. end
  133. until not distances[2]
  134. local zombie = distances[1][2]
  135. print(zombie, distances[1][1]) --debug
  136. hrp.CFrame = zombie.HumanoidRootPart.CFrame
  137. end)
  138. end
  139. end)
  140. game.Players.LocalPlayer.Character.Head:Destroy()
  141.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement