Advertisement
Guest User

Booga Booga Reborn

a guest
Oct 8th, 2022
4,881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local TweenService = game:GetService("TweenService")
  4. local ui = loadstring(game:HttpGet("https://raw.githubusercontent.com/Singularity5490/rbimgui-2/main/rbimgui-2.lua"))()
  5. local window = ui.new({text="autofarm"})
  6. local tab = window.new({text = "main"})
  7. local autofarmToggle = tab.new("Switch", {text="autofarm"})
  8.  
  9. -- wrote this myself :sunglasses:
  10. local function getClosestObject(folder)
  11. local distance, part = math.huge, nil
  12. local mainPart
  13. for i,v in pairs(folder:GetChildren()) do
  14. local HRPPosition = Players.LocalPlayer.Character.HumanoidRootPart.Position
  15.  
  16. for i2,v2 in pairs(v:GetChildren()) do
  17. if v2:IsA("BasePart") then
  18. mainPart = v2
  19. break
  20. end
  21. end
  22.  
  23. if mainPart and not mainPart.Parent:FindFirstChild("Humanoid") and mainPart.Parent:FindFirstChild("Health") then
  24. local realDistance = math.abs((HRPPosition - mainPart.Position).Magnitude)
  25.  
  26. if realDistance < distance then
  27. distance = realDistance
  28. part = mainPart
  29. end
  30. end
  31. end
  32. return part
  33. end
  34.  
  35. local function getClosestPickups(folder)
  36. local pickups = {}
  37. for i,v in pairs(folder:GetChildren()) do
  38. if v:FindFirstChild("Pickup") and v:IsA("BasePart") and table.find(pickups,v) == nil then
  39. if (Players.LocalPlayer.Character.HumanoidRootPart.Position - v.Position).Magnitude <= 30 then
  40. table.insert(pickups, v)
  41. end
  42. end
  43. end
  44. return pickups
  45. end
  46.  
  47.  
  48. while wait(0.3) do
  49. if autofarmToggle.on then
  50. local part = getClosestObject(workspace)
  51. local HRPPosition = Players.LocalPlayer.Character.HumanoidRootPart.Position
  52. local realDistance = math.round(math.abs((HRPPosition - part.Position).Magnitude))
  53.  
  54. ReplicatedStorage.Events.SwingTool:FireServer(ReplicatedStorage.RelativeTime.Value, {
  55. [1] = part
  56. })
  57. for i,v in pairs(getClosestPickups(workspace)) do
  58. game:GetService("ReplicatedStorage").Events.Pickup:FireServer(v)
  59. end
  60. wait(0.1)
  61. if part.Position.Y <= 30 then
  62. TweenService:Create(Players.LocalPlayer.Character.HumanoidRootPart, TweenInfo.new(realDistance/10, Enum.EasingStyle.Linear), {CFrame=part.CFrame+Vector3.new(0,part.Size.Y,0)}):Play()
  63. task.wait(realDistance/10)
  64. end
  65. end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement