Why does this while loop give me an error?

You can’t have a ‘delay’ within the body of any blueprint loop or function. They don’t play nice together, remove the delays and see if the error goes away. I believe what is happening is the loop function doesn’t actually wait for the delay before executing again and since you have 2 seconds total of delay in this loop body. So the while loop executes continuously for 2 seconds before ever reaching the increment node. In that the number of loop executions exceeds the safety limit set within the engine itself and it crashes.