Issue with Humanoid:Move() looking jittery

I have an NPC whose job is to track down the player once they are within its range. Everything works fine enough, but there’s an issue that’s causing me to tear my hair out trying to figure out a solution.
Below is a video of the NPC in action.

If you pay attention, you’ll notice the NPC, as oppose to smoothly moving from point A to point B, teleports around towards its final destination. This bugs me mainly because of visual appeal, or lack thereof, when the NPC does this.

I have attempted to search through solutions, but all of them are either regarding :MoveTo() (which doesn’t work for me for some reason) or aren’t smooth for a reason that doesn’t apply to me.

I don’t know why it’s doing this and I’m genuinely stuck.

I’ve provided the important part of the code below, which is placed within a loop that runs every RunService.Stepped (I apologize for the messy code):

if detectiontick > 50 then
	if detectiontick == 70 then
		script.Parent.Parent.Parent.Humanoid.Animator:LoadAnimation(script.Run):Play()
		script.Parent.Parent.Parent.Humanoid.WalkSpeed = 22

		game.ReplicatedStorage.NPC.Tools.StunGunVisual:Clone().Parent = script.Parent.Parent.Parent
					
	end
	task.delay(0.1, function()
		if script.Detecting.Value ~= nil then
			script.Parent.Parent.Parent.HumanoidRootPart.CFrame = script.Parent.Parent.Parent.HumanoidRootPart.CFrame:Lerp(CFrame.lookAt(script.Parent.Parent.Parent.HumanoidRootPart.Position, Vector3.new(target.Position.X, script.Parent.Parent.Parent.HumanoidRootPart.Position.Y, target.Position.Z)), 0.25)	
		end
	end)

	if detectiontick/50 == math.round(detectiontick/50) then
		dist = 20
		script.Parent.Parent.Parent.Humanoid.AutoRotate = false
		script.Parent.Parent.Parent.Humanoid:Move((target.Position - script.Parent.Parent.Position))
	end
end

Help would be greatly appreciated.

1 Like

If you haven’t already, you could try to set network ownership to the client.

2 Likes

what is ‘detectiontick’ defined as?

2 Likes

“detectiontick” is a value that increases every time the loop is run and a player is actively being detected. If no player is detected, it is reset to 0.

I have just attempted this, and while it did help a little bit, it was still noticeably jittery. Also, since the client now owns the rig’s HRP, it may raise security concerns, especially considering I want this to be a multiplayer game.

Edit #1: Replaced “HRE” with “HRP”. No idea why I even wrote HRE in the first place, considering I was intending to abbreviate “HumanoidRootPart”…

Sorry for the late reply, but could you explain why your lerping?