minecrafter206

AutoFarm

May 31st, 2021
1,120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --OP AutoFarm
  3. local Player = game:GetService("Players").LocalPlayer
  4. local Character = Player.Character or Player.CharacterAdded:Wait()
  5. local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
  6.  
  7.  
  8.  
  9. for _,i in pairs(game:GetService("Workspace"):GetChildren()) do
  10.    
  11.     if i:IsA("Part") and i:FindFirstChild("Health") then
  12.             local tween = game:GetService("TweenService"):Create(game.Players.LocalPlayer.Character.HumanoidRootPart, TweenInfo.new(0, Enum.EasingStyle.Linear), {CFrame = i.CFrame})
  13.             tween:Play()
  14.             tween.Completed:Wait()
  15.             local newRay = Ray.new(HumanoidRP.CFrame.p, Vector3.new(0,-1,0).unit * 10)
  16.             local Hit = game:GetService("Workspace"):FindPartOnRay(newRay, Character)
  17.  
  18.             if Hit then
  19.                 game:GetService("ReplicatedStorage").Comm.Events.Dug:FireServer(Hit)
  20.             end
  21.  
  22.             local newRay2 = Ray.new(HumanoidRP.CFrame.p, Vector3.new(0,0,1).unit * 10)
  23.             local Hit2 = game:GetService("Workspace"):FindPartOnRay(newRay2, Character)
  24.  
  25.             if Hit2 then
  26.                 game:GetService("ReplicatedStorage").Comm.Events.Dug:FireServer(Hit2)
  27.             end
  28.  
  29.             local newRay3 = Ray.new(HumanoidRP.CFrame.p, Vector3.new(0,0,-1).unit * 10)
  30.             local Hit3 = game:GetService("Workspace"):FindPartOnRay(newRay3, Character)
  31.  
  32.             if Hit3 then
  33.                 game:GetService("ReplicatedStorage").Comm.Events.Dug:FireServer(Hit3)
  34.             end
  35.  
  36.             local newRay4 = Ray.new(HumanoidRP.CFrame.p, Vector3.new(1,0,0).unit * 10)
  37.             local Hit4 = game:GetService("Workspace"):FindPartOnRay(newRay4, Character)
  38.  
  39.             if Hit4 then
  40.                 game:GetService("ReplicatedStorage").Comm.Events.Dug:FireServer(Hit4)
  41.             end
  42.  
  43.             local newRay5 = Ray.new(HumanoidRP.CFrame.p, Vector3.new(-1,0,0).unit * 10)
  44.             local Hit5 = game:GetService("Workspace"):FindPartOnRay(newRay5, Character)
  45.  
  46.             if Hit5 then
  47.                 game:GetService("ReplicatedStorage").Comm.Events.Dug:FireServer(Hit5)
  48.             end
  49.             wait()
  50.     end
  51.     wait()
  52. end
RAW Paste Data