Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

NPC moves smooth but begins to stutter after a while, what's the matter?

So the NPC moves smoothly to the destination once or twice but then starts to pause at each waypoint for an unknown reason, or, at least unknown to me... I asked this in the Discord server a few times, but nothing I tried from there works. What can I do to fix it?

while true do
	local post = campPosts[math.random(1, #campPosts)]
	path:ComputeAsync(torso.Position, post.Position)
	local waypoints = path:GetWaypoints()
	for i, v in pairs(waypoints) do
		if v.Action == Enum.PathWaypointAction.Jump then
			humanoid.Jump = true
		end
		humanoid:MoveTo(v.Position, post)
		humanoid.MoveToFinished:Wait()
		path.Blocked:Connect(function()
			path:ComputeAsync(torso.Position, post.Position)
		end)
	end
	print("lastHere")
	if post.Name == "optionalPost" then
		wait(5)
	elseif post.Name == "importantPost" then
		wait(30)
	elseif post.Name == "mandatoryPost" then
		break
	end
end

3 comments

0

why do you have the break there on 22? it doesnt serve a purpose. you can put "return end" but I have no clue why you put break, thats usually only used for "for i" loops

0

this wont effect anything btw, i just noticed it

0

the return would be inside the elseif tho and I want to break the loop so it doesn't go to another post

1 answer

✓ Accepted answer

Set the Network Ownership to the Server. Automatic network ownerships tends to hop between both client and server depending on the proximity of the nearest client, and as there will always be a slight desync due to latency, some objects and entities may appear to "skip" or "hop", or in your case, stutter.

This discussion is preserved as it was. New answers, comments, and votes are closed.