Advertisement
ProScripter29

Universal Sword Autofarm V2

May 29th, 2024 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2.  
  3. local Players = game:GetService("Players")
  4.  
  5. local CurrentPlayer
  6.  
  7. local function PlayerAlive(Player)
  8. if Player and Player.Character then
  9. if Player.Character:FindFirstChild("HumanoidRootPart") and Player.Character:FindFirstChild("Humanoid") and Player.Character.Humanoid.Health > 0 then
  10. if not Players.LocalPlayer or not Players.LocalPlayer.Character or not Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then return nil, nil end
  11. if (Player.Character.HumanoidRootPart.Position - Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude <= _G.SwordAutofarmRange then
  12. return Player, Player.Character
  13. end
  14. end
  15. end
  16. return nil, nil
  17. end
  18.  
  19. local Angle = 1.5
  20. local R = true
  21.  
  22. RunService.Heartbeat:Connect(function()
  23. if R == true then
  24. Angle -= 0.75
  25. if Angle <= 0 then
  26. R = false
  27. end
  28. else
  29. Angle += 0.75
  30. if Angle >= 1.5 then
  31. R = true
  32. end
  33. end
  34. if CurrentPlayer and CurrentPlayer.Character and CurrentPlayer.Character:FindFirstChild("HumanoidRootPart") and CurrentPlayer.Character.Humanoid.Health > 0 then
  35. if Players.LocalPlayer and Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
  36. if CurrentPlayer.Character.Humanoid.Jump == true then
  37. Players.LocalPlayer.Character.Humanoid.Jump = true
  38. end
  39. Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.lookAt(Players.LocalPlayer.Character.HumanoidRootPart.Position, Vector3.new(CurrentPlayer.Character.HumanoidRootPart.Position.X + Angle, Players.LocalPlayer.Character.HumanoidRootPart.Position.Y, CurrentPlayer.Character.HumanoidRootPart.Position.Z))
  40. end
  41. end
  42. end)
  43.  
  44. RunService.RenderStepped:Connect(function()
  45. if not (_G.TargetPlayerName == nil) then
  46. local Player = Players:FindFirstChild(_G.TargetPlayerName)
  47. if Player then
  48. if not (Player == Players.LocalPlayer) then
  49. local Player, Character = PlayerAlive(Player)
  50. if Player and Character then
  51. local Tool = Players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
  52. if Tool and Tool:IsA("Tool") and Tool:FindFirstChild("Handle") then
  53. Tool:Activate()
  54. CurrentPlayer = Player
  55. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 0)
  56. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 1)
  57. end
  58. end
  59. end
  60. end
  61. elseif (_G.KillWhenTouched == true) then
  62. if Players.LocalPlayer and Players.LocalPlayer.Character then
  63. local Tool = Players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
  64. if Tool and Tool:FindFirstChild("Handle") then
  65. for i, Part in pairs(workspace:GetPartsInPart(Tool.Handle)) do
  66. local Player, Character = Players:GetPlayerFromCharacter(Part.Parent)
  67. if Player and Character then
  68. local Alive = PlayerAlive(Player)
  69. if Alive then
  70. Tool:Activate()
  71. CurrentPlayer = Player
  72. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 0)
  73. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 1)
  74. end
  75. end
  76. end
  77. end
  78. end
  79. else
  80. for i, Player in pairs(Players:GetPlayers()) do
  81. if not (Player == Players.LocalPlayer) then
  82. local Player, Character = PlayerAlive(Player)
  83. if Player and Character then
  84. local Tool = Players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
  85. if Tool and Tool:IsA("Tool") and Tool:FindFirstChild("Handle") then
  86. Tool:Activate()
  87. CurrentPlayer = Player
  88. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 0)
  89. firetouchinterest(Tool.Handle, Character.HumanoidRootPart, 1)
  90. end
  91. end
  92. end
  93. end
  94. end
  95. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement