System to know when Pathfinding AI is stuck in a wall

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

So I’m making a monster that moves to waypoints inside a maze. I want it to be like The Mimic. The monster sometimes gets stuck tho because the agent radius doesn’t always get calculated by Roblox. So when it does get stuck I want to fire an event which will stop the monster from moving. Then moves it back to the start of the maze and does the whole path over again.

  1. What is the issue? Include screenshots / videos if possible!

How do I know when the monster is stuck In place or has it’s head stuck in a wall because that happens a lot with my meshes.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I try rounding off the position of the monster 0.3 seconds ago and rounding off the position right now. Then I check if the rounded of positions are the same. If they are then I fire the event. It’s very buggy and inefficient tho. For example when it reaches a waypoint it stops for like 0.1 seconds. There is a tiny chance it would then teleport back to spawn. I want the players to not see it randomly teleport. If anyone has any other ideas I would appreciate it.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I have tried path.Status but it doesn’t help. Also when I have a character with a humanoid, it automatically turns the collisions on for all the parts inside the character. So meshes too. Those meshes sometimes go into the wall even tho the agent radius is set bigger than the diameter of the character divided by 2. Even when I turn CanCollide off the meshes still collide with other parts. And making CollisionGroups is not going to work either because it will go through the walls.

This is my current solution and as I said, it’s very inefficient.
The function OverwritePath() teleports the monster and stuff.
The Variable PrimaryPart is the HumanoidRootPart of my monster

function roundNumber(number, numberDecimalPlaces)
	return tonumber(string.format("%." .. (numberDecimalPlaces or 0) .. "f", number))

	while wait(0.3) do
		local count = 0
		if roundNumber(lastposX,1) == roundNumber(PrimaryPart.Position.X,1) then
			count += 1
		if roundNumber(lastposZ,1) ==roundNumber(PrimaryPart.Position.Z,1) then
			count += 1
		lastposX = PrimaryPart.Position.X
		lastposZ = PrimaryPart.Position.Z
		if count == 2 then

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.