[RESOLVED] Glitchy NPC Walk

So, I decided to make a simple NPC follow script and I took the plunge. I did it, however, the NPC movement stutters horribly and some walk absolutely slow even though they have the same speed. Does anyone know what this could be?

Script that moves the NPC:

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://180426354"

while wait() do
	if script.Parent.Contents.Follow.Value == true and script.Parent.Contents.NPC.Value == 0 then
		local GetOwner = script.Parent.Contents.Owner.Value
		local Distance = (script.Parent.PrimaryPart.Position - game.Workspace[GetOwner].PrimaryPart.Position).Magnitude
		
		if Distance > 3 then
			local LoadAnim = script.Parent.Humanoid:LoadAnimation(animation)
			LoadAnim.Looped = true
			script.Parent.Humanoid:MoveTo((game.Workspace[GetOwner].HumanoidRootPart.CFrame*CFrame.new(0,0,3)).p)	
			LoadAnim:Play()
			script.Parent.Humanoid.MoveToFinished:Wait()
			LoadAnim:Stop()
		end
	else
		local GetNPC = script.Parent.Contents.NPC.Value
		local NPC = game.Workspace.NPC:FindFirstChild(GetNPC)
		local Distance = (script.Parent.PrimaryPart.Position - game.Workspace.NPC[GetNPC].PrimaryPart.Position).Magnitude
		if Distance > 3 then
			local LoadAnim = script.Parent.Humanoid:LoadAnimation(animation)
			LoadAnim.Looped = true
			script.Parent.Humanoid:MoveTo((NPC.HumanoidRootPart.CFrame*CFrame.new(0,0,3)).p)
			LoadAnim:Play()
			script.Parent.Humanoid.MoveToFinished:Wait()
			LoadAnim:Stop()
		end
	end
end

Thanks for any help.

2 Likes

Oh, also everytime the NPC spawns it has folder with 3 values inside of him
His owner, if he has to still follow him and number of previous NPC.
image

1 Like

Try setting the network owner of all the NPC’s parts to the server

1 Like

Tried it just now and it still feels the same. However thanks for trying to help!
Yet their animation is still glitching out and is not smooth.

It’s most likely because you are constantly starting and stopping the animation.

2 Likes

Oh, right! Thanks!
By setting the network owner to server & giving the NPCs their own “Animate” script I fixed it.

1 Like

and how do you change that? Can u explain