Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local function gethumanoids()
- local humanpos = {}
- for a, b in pairs(game.Workspace:GetChildren()) do
- if b:FindFirstChild("Humanoid") and b ~= script.Parent then
- local name = b.Name
- if game.Players:FindFirstChild(name) then
- table.insert(humanpos,(script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude)
- end
- end
- end
- table.sort(humanpos)
- for a, b in pairs(humanpos) do
- if a ~= 1 then
- table.remove(humanpos.a)
- end
- end
- for a, b in pairs(game.Workspace:GetChildren()) do
- if b:FindFirstChild("Humanoid") and b ~= script.Parent then
- local name = b.Name
- if game.Players:FindFirstChild(name) then
- if (script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude == humanpos[1] then
- return b
- end
- end
- end
- end
- end
- while true do
- local path = game:GetService("PathfindingService"):CreatePath()
- path:ComputeAsync(script.Parent.HumanoidRootPart.Position, gethumanoids().HumanoidRootPart.Position)
- local points = path:GetWaypoints()
- script.Parent.AttackingPlayer.Value = gethumanoids().Name
- script.Parent.Parent.Points:ClearAllChildren()
- for a, b in pairs(points) do
- part = Instance.new("Part")
- part.CanCollide = false
- part.Size = Vector3.new(1,1,1)
- part.Position = b.Position
- part.Anchored = true
- part.Transparency = 1
- part.Parent = script.Parent.Parent.Points
- end
- if path.Status == Enum.PathStatus.Success then
- for a, b in pairs(points) do
- script.Parent.Humanoid:MoveTo(part.Position)
- if b.Action == Enum.PathWaypointAction.Jump then
- script.Parent.Humanoid.Jump = true
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement