Auto-translated
landw1rt, it's not entirely clear which lines you're adding where and at what point the game crashes. It's possible that the GetAllNames() function returns a string, not a table. Also, you can get the heroes of a specific player using the GetPlayerHeroes(PLAYER_NUMBER) function.
I'm adding the specified snippet to the script body to check if the region is unoccupied. By iterating, I determined that the game crashes after adding this snippet.
The same thing happens with the length function.
GetAllNames() prints a list of living heroes to the console, but problems start after the for loop.
I only need to count the number of values returned by GetAllNames().