NPC stutter (BIG ISSUE)

Hello guys, recently i’ve been running into stuttering issues with the npcs and not sure what it is?

Here’s the video: robloxapp-20240704-1610456.wmv (1.9 MB)

2 Likes

Please provide the code for the NPC’s movement. If you’re posting in scripting support you need to provide the scripts otherwise people don’t know how to respond.

3 Likes

local function MoveToPosition(Position:"Position", Student:"Student", CurrentLesson:"CurrentLesson", IfInDetention:"Detention",ContinueNoMatterWhat:"Continue path regardless of any params")
	local Path = PathfindingService:CreatePath({WaypointSpacing = 1, AgentRadius = Student:GetExtentsSize().X / 2, AgentHeight = Student:GetExtentsSize().Y, AgentCanJump = true, AgentCanClimb = true})
	Path:ComputeAsync(Student:WaitForChild("HumanoidRootPart").Position, Position)

	local Waypoints = Path:GetWaypoints()

	local Blocked = false
	local broke = false

	for i, v in pairs(Waypoints) do
		Student:WaitForChild("Humanoid"):MoveTo(v.Position)
		Student:WaitForChild("Humanoid").MoveToFinished:Wait()
		
		Path.Blocked:Connect(function(CurrentIndex)
			if i <= CurrentIndex or i >= CurrentIndex then
				Blocked = true
			end
		end)
		
		if Student:GetAttribute("Stop") and not ContinueNoMatterWhat then
			broke = true
			break
		end

		if Student:GetAttribute("Exclude") and not ContinueNoMatterWhat then
			broke = true
			break
		end

		if IfInDetention and Student:GetAttribute("Detention") and not ContinueNoMatterWhat then
			broke = true
			break
		end

		if CurrentLesson ~= nil and not ContinueNoMatterWhat then
			if Functions.CheckPeroids(CurrentLesson) then
				broke = true
			end
		end

		if broke == true then 
			break
		end

		if Blocked == true then
			break
		end

		if v.Action == Enum.PathWaypointAction.Jump then
			Student:WaitForChild("Humanoid"):ChangeState(Enum.HumanoidStateType.Jumping)
		end

		if Student:WaitForChild("Humanoid").Sit == true then
			Student:WaitForChild("Humanoid").Jump = true
		end
		if Student:GetAttribute("Fight") and not ContinueNoMatterWhat then
			broke = true
		end
	end
	
	if broke == true then
		return true
	end

	if Blocked == true then
		MoveToPosition(Position, Student, CurrentLesson)
		--return "Blocked"
	end
end
1 Like

Is your NPC’s NetworkOwner set to nil?

1 Like

Yes, I set the characters parts and its primaryparts networkownership to nil

1 Like

Hmm… This problem was happening with me, too, but the solution was to set the HRP’s ownership to nil… Odd.

1 Like

Add print statements to the section that is actually moving the humanoid and see if it’s being spammed in the output and send a screenshot

I think that’s the issue, it seems to be spamming it every millisecond

I’ll try visualising the path and seeing if its 100% the issue.

That’s what I figured. Try removing some of those break statements because you have quite a lot. MoveTo really only needs to be run once so it doesn’t need to move like one stud at a time.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.