while true do
local Target = GetClosestPlayer(400)
print(Target)
if Target ~= nil then
if Target.Character ~= nil then
Humanoid:MoveTo(Target.Character.PrimaryPart.Position)
Humanoid.MoveToFinished:Wait()
end
else
wait()
end
end
Now we should only call a wait call once.
However, you are yeilding the next loop iteration until after either a wait() or a MoveToFinished:Wait().
Try this, and then see how it works, you may experience less stutter, but I think there will still be some.
I may be wrong or I may NOT be wrong, but I just encountered this problem. I noticed that it only happens when you get within a certain vicinity so it could be an issue with replication to client, etc. I solved it by iterating through the NPC, getting all BasePartās, and doing BasePart:SetNetworkOwner(nil) to make the Server the network owner for the part. This eliminated the laggy choppy movement it used to have.