Weird exhausted execution time that never happened before

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!
    Figure out what is causing this.

  2. What is the issue? Include screenshots / videos if possible!
    I’ve been trying to find a new way to implement pathing, and the section of code that is apparently failing has been tested before and was working fine. It only started to fail after some new implementations, however those new implementations are in a separate function, and the call is commented out, so it is the while loop. I just don’t know why.

Each time a player right clicks with a selected unit it will fire an event to move the AI to the desired hex. Before the script below comes into play, there is another section of code that just creates a part and stretches it between the selected hex (or desired hex) and the start hex for the unit. It gathers all of the parts it touches into an array and deletes the part. Afterwards, the script below is used. It compares to the array previously mentioned. The array has all the parts properly grabbed, so it shouldn’t be an issue.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Literally scanned through it several times and tried to figure out. Could not see the reason why it suddenly broke.
while #listOfIgnoredHexs ~= #tableOfRayTouch do
				local rayOrigin = game.Workspace[startHex].HexTile.CFrame.p
				local rayDestination = game.Workspace[hexName].HexTile.CFrame.p
				local rayDirection = rayDestination - rayOrigin
				local ray =, rayDirection)
				local hitParts, hitPositions = workspace:FindPartOnRayWithIgnoreList(ray, listOfIgnoredHexs)
				if hitParts then
					if string.match(hitParts.Parent.Name, 'Hex') then
						if #listOfIgnoredHexs ~= #tableOfRayTouch then
							table.insert(listOfIgnoredHexs, hitParts.Parent)

This is what is failing. Regarding the functionality of it, it does its job exactly as it should. I have no idea what is causing the issue.

I figured out the problem. At times there are two hex that the ray hits, but only accounts for one.