Any ways to disable an NPC's movement?

Hello! I have been working on a game for the past couple of months. More specifically, I have been working on a slime enemy. Everything works fine, but there was a small issue I’d like to fix but I haven’t been able to think of a way to fix it.

Essentially, the enemy pathfinds (only when it cannot directly see the enemy, otherwise it just walks to them).

It is normally intended to stop moving after jumping, but due to the way pathfinding works (moving to each individual node) it moves even after it lands.

I was wondering if there are any ways to disable the NPC’s movement? (Without changing walkspeed or anchoring it.)

idk for sure how you did this but im guessing something like this would work

Humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Landed then
		Humanoid:MoveTo(HumanoidRootPart.Position)
	end
end)

I reckon there are methods for stopping an NPC’s movement. You can try to use Humanoid:MoveTo([its own position currently]) to try to interrupt the path.

A solution similar is:

My issue is unfortunately not with getting the enemy to stop moving while it’s already moving; it’s to prevent the enemy from moving whenever it uses the move function.

Although I do think I have an idea on how to fix it. Will update if this works.

we usually add a continue, break, or return before using the move function

Okay, so it didn’t work.

If any future forum user sees this and wants to help; PLEASE realize that my issue is making it so future movements don’t work. And I can’t use Walkspeed as a feature (ie setting it to zero) because that will create conflict with other features in the game.

after the jump, break the pathfinding loop and move the slime to its current position to stop current movement

Also it’s suggested to not use a loop for pathfinding, but signals instead.

if thats the issue just put this into the loop

Humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Landed then
		break
	end
end)