heres the video of what i mean
local runService = game:GetService("RunService")
local players = game:GetService("Players")
local pathfindingService = game:GetService("PathfindingService")
local bots = workspace.bots
local path = pathfindingService:CreatePath({
AgentRadius = 0.5,
AgentHeight = 4,
WaypointSpacing = 30,
AgentCanJump = true,
AgentCanClimb = true,
Costs = {
Climb = 0.85,
Launchable = 1.01,
Jump = 10,
Hydrant = 20,
Travel = 1
}
})
local function getNearestPlayer(from)
local shortestDistance, shortestFrom = 999999999999, nil
for _, player in players:GetPlayers() do
if player.Character then
local humanoidRootPart = player.Character.HumanoidRootPart
local distance = (from - humanoidRootPart.Position).Magnitude
if distance <= shortestDistance then
shortestDistance = distance
shortestFrom = player
end
end
end
return shortestFrom, shortestDistance
end
runService.Heartbeat:Connect(function(step)
for _, bot in bots:GetChildren() do
local player, distance = getNearestPlayer(bot.HumanoidRootPart.Position)
if player then
path:ComputeAsync(bot.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _, waypoint in waypoints do
bot.Humanoid:MoveTo(waypoint.Position)
bot.Humanoid.MoveToFinished:Wait()
end
end
end
end
end)
if i should guess im gussing its because of the runservice loop since it’d be creating so many paths but idk