Advertisement
KenshiOfficial

Baddies auto farm

Aug 17th, 2024
2,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. -- Create the GUI and button
  2. local player = game.Players.LocalPlayer
  3. local screenGui = Instance.new("ScreenGui")
  4. screenGui.Parent = player:WaitForChild("PlayerGui")
  5.  
  6. local toggleButton = Instance.new("TextButton")
  7. toggleButton.Size = UDim2.new(0, 200, 0, 50)
  8. toggleButton.Position = UDim2.new(1, -210, 0.5, -25) -- Position the button to the right side of the screen
  9. toggleButton.AnchorPoint = Vector2.new(1, 0.5) -- Anchor the button to the right center
  10. toggleButton.Text = "Start Farming"
  11. toggleButton.Parent = screenGui
  12.  
  13. -- Initialize farming state
  14. getgenv().farm = false
  15.  
  16. -- Function to toggle farming
  17. local function toggleFarming()
  18. getgenv().farm = not getgenv().farm
  19. toggleButton.Text = getgenv().farm and "Stop Farming" or "Start Farming"
  20. end
  21.  
  22. -- Connect the button to the toggle function
  23. toggleButton.MouseButton1Click:Connect(toggleFarming)
  24.  
  25. -- Main farming script
  26. local cash = workspace.Cash
  27. local dmg = workspace.Damageables
  28.  
  29. for _, v in next, getconnections(player.Idled) do
  30. v:Disable()
  31. end
  32.  
  33. local function getMoney()
  34. for _, m in pairs(cash:GetChildren()) do
  35. if m.Name == "Cash" and (m.Position - player.Character.HumanoidRootPart.Position).magnitude <= 20 then
  36. player.Character.HumanoidRootPart.CFrame = m.CFrame
  37. wait(.2)
  38. fireproximityprompt(m.ProximityPrompt, 6)
  39. wait(.35)
  40. end
  41. if not getgenv().farm then
  42. break
  43. end
  44. end
  45. end
  46.  
  47. while true do
  48. wait(1)
  49. if getgenv().farm then
  50. pcall(function()
  51. for _, a in ipairs(dmg:GetChildren()) do
  52. if not getgenv().farm then
  53. break
  54. end
  55. if a.Damageable.Value > 0 then
  56. player.Character.HumanoidRootPart.CFrame = a.Screen.CFrame * CFrame.new(0, 0, 2)
  57. wait(1)
  58. repeat
  59. if not getgenv().farm then
  60. break
  61. end
  62. player.Character.HumanoidRootPart.CFrame = a.Screen.CFrame * CFrame.new(0, 0, 2)
  63. game:GetService("ReplicatedStorage"):WaitForChild("PUNCHEVENT"):FireServer(1)
  64. wait(.5)
  65. until a.Damageable.Value <= 0
  66. wait(1)
  67. getMoney()
  68. end
  69. end
  70. end)
  71. end
  72. end
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement