Advertisement
FXDuke

Puddle Auto Farm

Aug 28th, 2022 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.99 KB | None | 0 0
  1.  
  2. local Players = game:GetService("Players")
  3. local Player = Players.LocalPlayer
  4. local puddleGroup = workspace:FindFirstChild("ActiveCastleStage"):FindFirstChild('CastleFloor1'):FindFirstChild('ActivePuddle')
  5.  
  6. local PathfindingService = game:GetService("PathfindingService")
  7. local Players = game:GetService("Players")
  8. local RunService = game:GetService("RunService")
  9.  
  10. local path = PathfindingService:CreatePath()
  11.  
  12. local player = Players.LocalPlayer
  13. local character = player.Character
  14. local humanoid = character:WaitForChild("Humanoid")
  15.  
  16. local TEST_DESTINATION = Vector3.new(100, 0, 100)
  17.  
  18. local waypoints
  19. local nextWaypointIndex
  20. local reachedConnection
  21. local blockedConnection
  22.  
  23. local dis2 = function(x1,x2,y1,y2,z1,z2)
  24.     return math.sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1))+((z2-z1)*(z2-z1)))
  25. end
  26.  
  27. local function getMop()
  28.     keypress(0x6F)
  29.     keyrelease(0x6F) -- /
  30.     wait(1)
  31.     keypress(0xBA)
  32.     keyrelease(0xBA) -- ;
  33.     keypress(0x4D)
  34.     keyrelease(0x4D) -- m
  35.     wait(0.1)
  36.     keypress(0x4F)
  37.     keyrelease(0x4F) -- o
  38.     wait(0.1)
  39.     keypress(0x50)
  40.     keyrelease(0x50) -- p
  41.     wait(0.1)
  42.     keypress(0x0D)
  43.     keyrelease(0x0D) -- enter
  44.     wait(0.5)
  45.     if not Player.Backpack:FindFirstChild("Mop") and not Player.Character:FindFirstChild("Mop") then
  46.         getMop()
  47.     else
  48.         Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  49.         run = true
  50.         return true;
  51.     end
  52. end
  53.  
  54. for _,v in pairs(workspace:FindFirstChild("ActiveCastleStage"):FindFirstChild('CastleFloor1'):GetDescendants()) do
  55.     if v.Name == "Door" then
  56.         v:Destroy()
  57.     end
  58. end
  59. local bambam = Instance.new("BodyThrust")
  60. bambam.Parent = Player.Character.HumanoidRootPart
  61. bambam.Force = Vector3.new(0,0,0)
  62. bambam.Location = Player.Character.HumanoidRootPart.Position
  63. local elapsed_time = 0
  64. local function followPath(destination)
  65.     -- Compute the path
  66.     local success, errorMessage = pcall(function()
  67.        
  68.         path:ComputeAsync(character.PrimaryPart.Position, destination)
  69.     end)
  70.  
  71.     if success and path.Status == Enum.PathStatus.Success then
  72.         -- Get the path waypoints
  73.         waypoints = path:GetWaypoints()
  74.  
  75.         -- Detect if path becomes blocked
  76.         blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
  77.             -- Check if the obstacle is further down the path
  78.             if blockedWaypointIndex >= nextWaypointIndex then
  79.                 -- Stop detecting path blockage until path is re-computed
  80.                 blockedConnection:Disconnect()
  81.                 -- Call function to re-compute new path
  82.                 humanoid.Jump = true
  83.                 followPath(destination)
  84.             end
  85.         end)
  86.  
  87.         -- Detect when movement to next waypoint is complete
  88.         if not reachedConnection then
  89.             reachedConnection = humanoid.MoveToFinished:Connect(function(reached)
  90.                 if reached and nextWaypointIndex < #waypoints then
  91.                     humanoid.Jump = true
  92.                     -- Increase waypoint index and move to next waypoint
  93.                     nextWaypointIndex = nextWaypointIndex + 1
  94.                     humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
  95.                 else
  96.                     reachedConnection:Disconnect()
  97.                     blockedConnection:Disconnect()
  98.                 end
  99.             end)
  100.         end
  101.         bambam.Force = Vector3.new(500,0,500)
  102.  
  103.         -- Initially move to second waypoint (first waypoint is path start; skip it)
  104.         nextWaypointIndex = 2
  105.         humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
  106.     end
  107. end
  108.  
  109. local run = false
  110.  
  111. local currentPuddle = nil
  112. local listener
  113. local function getPuddle()
  114.     for _,v in pairs(puddleGroup:GetChildren()) do
  115.         if v:IsA("Model") then
  116.             local p1 = Player.Character.HumanoidRootPart.Position
  117.             local p2 = v:FindFirstChildOfClass("Part").Position
  118.             if dis2(p1.X,p2.X,p1.Y,p2.Y,p1.Z,p2.Z) < 175 then
  119.                 currentPuddle = v
  120.                 listener = currentPuddle:FindFirstChildOfClass("Part").Destroying:Connect(function()
  121.                     elapsed_time = 0
  122.                     currentPuddle = nil
  123.                 end)
  124.                
  125.                 return followPath(v:FindFirstChildOfClass("Part").Position);
  126.             else
  127.                 return nil;
  128.             end
  129.         end
  130.     end
  131. end
  132.  
  133. Player.Chatted:Connect(function(msg)
  134.     if msg == ";begin" then
  135.         if Player.Backpack:FindFirstChild("Mop") then
  136.             Player.Backpack:FindFirstChild("Mop").Parent = Player.Character
  137.             Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  138.             run = true
  139.             getPuddle()
  140.         end
  141.         if not Player.Backpack:FindFirstChild("Mop") and not Player.Character:FindFirstChild("Mop") then
  142.             getMop()
  143.             wait(0.1)
  144.             Player.Backpack:FindFirstChild("Mop").Parent = Player.Character
  145.             Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  146.             run = true
  147.             getPuddle()
  148.         end
  149.         if Player.Character:FindFirstChild("Mop") then
  150.             Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  151.             run = true
  152.             getPuddle()
  153.         end
  154.        
  155.     elseif msg == ";stop" then
  156.         run = false
  157.         bambam.Force = Vector3.new(0,0,0)
  158.     elseif msg == ";gettime" then
  159.         print(elapsed_time)
  160.     end
  161. end)
  162.  
  163.  
  164.  
  165. game:GetService('RunService').Heartbeat:Connect(function(dt)
  166.     elapsed_time = elapsed_time + dt
  167.     if currentPuddle == nil and run == true  then
  168.         currentPuddle = getPuddle()
  169.     end
  170.     if run == false then
  171.         bambam.Force = Vector3.new(0,0,0)
  172.     end
  173.     if elapsed_time > 60 then
  174.         print("Pathfinding: Time limit has been reached")
  175.     end
  176.     if elapsed_time > 60 and run == true then
  177.         warn("Pathfinding: Gave up on puddle")
  178.         for _,v in pairs(puddleGroup:GetChildren()) do
  179.             if v == currentPuddle then
  180.                 listener:Disconnect()
  181.                 v:Destroy()
  182.             end
  183.         end
  184.         currentPuddle = nil
  185.         elapsed_time = 0
  186.         Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  187.     end
  188. end)
  189.  
  190.  
  191. Player.Character.Humanoid.Died:Connect(function()
  192.     getMop()
  193.     Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
  194.     getPuddle()    
  195. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement