So i have an NPC that uses pathfindingservice to move and i made a pathfinding script but the issue is when it walks it like moves stud by stud to the destination even tho i have given it the destination position correctly, im not sure what is the issue, there are no scripting errors it just works not as intended it moves in a way i dont want it to move, i printed the destination and the waypoint and they have a difference and im not sure why even tho i have given correct position.
More information: when it moves to the stud the script like restarts but still move to the same destination instead of moving on to another destination
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath()
path:ComputeAsync(root.position, Pos)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
print("move")
walking = true
humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
print("stop")
walking = false
executed = false
wait(2)
value.Value = false
end