How to avoid npc stuttering?

The npc is still stuttering when pathfinding :confused:

Remove this line. Also don’t even put task.wait() now and see if it works

When I removed the task wait it would say “exhausted allowed execution time” in output and when i removed movetofinished it wont pathfind at all

What is this function checkSight() ?

It checks when the target is in a clear line of sight and if they are then it moves to their position

What is the point of that though? I don’t think its needed

If I remove it then the npc will move to where the target previously was instead of target position

Are you trying to make a system where the npc chases a player?

yes and the player is the target

Is there anything else I could try?

Waits are actually SUPER important and can be the difference between a 0.015-second delay to ensure the system doesn’t encounter an exhaust, and the system failing because of an exhaust. It is actually more so encouraged to use them, and they ONLY wait the said amount of time, no more or less. However, in the instance of this script, it would be better to use task.delay.

I recommend using task.delay(humanoid:MoveTo(), 0.01) in this instance, instead of task.wait! (task.wait is always good, however, task.delay does the same thing, just you can control it better!)

The pathfinding issue is still not fixed

Not to disappoint you, but I haven’t figured this out as well. I would instead use something else than the pathfinding service ROBLOX gives you, as its really bad. You can either raycast the npc to its target or use a custom pathfinding module to help you. (Legacy) SimplePath - Pathfinding Module - #33 by V3N0M_Z

delay isn’t really encouraged because it stacks up as the game runs longer.

Sorry for not replying. I actually had a solution then but my computer just started glitching real bad

local path = pathfindingService:CreatePath(agentParams)
path:ComputeAsync(humanoidRootPart.Position, target.Position)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
    waypoints = path:GetWaypoints()
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		humanoid.Jump = true
	end
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait()
end

This could work though I’m not very sure

Without the checksight function the AI is really bad, I don’t think that’s the problem

Have you at all thought of the NPC’s network owner? You should set it to nil so no client can manipulate it.

The npcs networkowner is nil though

Oh ok I didn’t see you setting it to nil. Plus you didn’t specify how you tested it.