messed around with some stuff and this seems to work
local Pathfind = game.PathfindingService
while wait(0.1) do
local human = script.Parent.Humanoid
local pos = human.RootPart.Position
local target = nil
local targetDistance = math.huge
local path = Pathfind:CreatePath({["WaypointSpacing"] = 32})
local op = OverlapParams.new()
op.FilterType = Enum.RaycastFilterType.Exclude
op.FilterDescendantsInstances = {script.Parent}
for _, i in workspace:GetPartBoundsInRadius(pos, 1000, op) do
if i.Name == "HumanoidRootPart" then
if (i.Position-pos).Magnitude < targetDistance then
path:ComputeAsync(pos, i.Position)
if path.Status == Enum.PathStatus.Success then
target = i.Position
targetDistance = (i.Position-pos).Magnitude
end
end
end
end
if target then
path:ComputeAsync(pos, target)
local waypoint = path:GetWaypoints()[2]
if waypoint.Action == 1 then
human.Jump = true
end
human:MoveTo(waypoint.Position)
end
end
local Pathfind = game.PathfindingService
local prevWaypoint = Vector3.zero
while wait(0.1) do
local human = script.Parent.Humanoid
local pos = human.RootPart.Position
local target = nil
local targetDistance = math.huge
local path = Pathfind:CreatePath({["WaypointSpacing"] = 32, ["AgentCanClimb"] = true})
local op = OverlapParams.new()
op.FilterType = Enum.RaycastFilterType.Exclude
op.FilterDescendantsInstances = {script.Parent}
for _, i in workspace:GetPartBoundsInRadius(pos, 1000, op) do
if i.Name == "HumanoidRootPart" and game.Players:GetPlayerFromCharacter(i.Parent) then
if (i.Position-pos).Magnitude < targetDistance then
path:ComputeAsync(pos, i.Position)
if path.Status == Enum.PathStatus.Success then
target = i.Position
targetDistance = (i.Position-pos).Magnitude
end
end
end
end
if target then
pos = human.RootPart.Position
path:ComputeAsync(pos, target)
if path.Status == Enum.PathStatus.Success then
local waypoint = path:GetWaypoints()[2]
if waypoint then
if prevWaypoint ~= waypoint.Position then
prevWaypoint = waypoint.Position
if waypoint.Action == 1 then
human.Jump = true
end
local move = Vector3.new((waypoint.Position-pos).X, 0, (waypoint.Position-pos).Z)
if move ~= Vector3.zero then
human:Move(move.Unit)
end
end
end
end
end
end