I am trying to get the AI bot to follow the player. I have made a function which gets all of the players near the AI bot, and it chooses the closest person, that works, but
This script doesnt work for some reason (There is nothing in the output). The AI bot doesn’t move:
function pathToLocation(target)
local path = game:GetService("PathfindingService"):CreatePath()
path:ComputeAsync(Btorso.Position, target.Position)
local waypoints = path:GetWaypoints()
for _,waypoint in ipairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
Bhumanoid.Jump = true
end
Bhumanoid:MoveTo(waypoint.Position)
end
end
"Btorso" is the AI torso "Bhumanoid is the AI humanoid" "target" is the player's torso