SHARE
TWEET

Untitled

a guest Apr 18th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wait(1)
  2. local function gethumanoids()
  3.     local humanpos = {}
  4.    
  5.     for a, b in pairs(game.Workspace:GetChildren()) do
  6.         if b:FindFirstChild("Humanoid") and b ~= script.Parent then
  7.             local name = b.Name
  8.             if game.Players:FindFirstChild(name) then
  9.                 table.insert(humanpos,(script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude)
  10.             end
  11.         end
  12.     end
  13.    
  14.     table.sort(humanpos)
  15.    
  16.     for a, b in pairs(humanpos) do
  17.         if a ~= 1 then
  18.             table.remove(humanpos.a)
  19.         end
  20.     end
  21.    
  22.     for a, b in pairs(game.Workspace:GetChildren()) do
  23.         if b:FindFirstChild("Humanoid") and b ~= script.Parent then
  24.             local name = b.Name
  25.             if game.Players:FindFirstChild(name) then
  26.                 if (script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude == humanpos[1] then
  27.                     return b
  28.                 end
  29.             end
  30.         end
  31.     end
  32. end
  33.  
  34.  
  35. while true do
  36.     local path = game:GetService("PathfindingService"):CreatePath()
  37.     path:ComputeAsync(script.Parent.HumanoidRootPart.Position, gethumanoids().HumanoidRootPart.Position)
  38.     local points = path:GetWaypoints()
  39.     script.Parent.AttackingPlayer.Value = gethumanoids().Name
  40.        
  41.     script.Parent.Parent.Points:ClearAllChildren()
  42.    
  43.     for a, b in pairs(points) do
  44.         part = Instance.new("Part")
  45.         part.CanCollide = false
  46.         part.Size = Vector3.new(1,1,1)
  47.         part.Position = b.Position
  48.         part.Anchored = true
  49.         part.Transparency = 1
  50.         part.Parent = script.Parent.Parent.Points
  51.     end
  52.    
  53.     if path.Status == Enum.PathStatus.Success then
  54.  
  55.         for a, b in pairs(points) do
  56.             script.Parent.Humanoid:MoveTo(part.Position)
  57.             if b.Action == Enum.PathWaypointAction.Jump then
  58.                 script.Parent.Humanoid.Jump = true
  59.             end
  60.         end    
  61.     end
  62. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top