landw1rt, this version of the for operator is designed to iterate through tables, but your function returns a string. Simply use GetPlayerHeroes():
local hero_cnt = 0;
for i = PLAYER_1, PLAYER_8 do
hero_cnt = hero_cnt + length(GetPlayerHeroes(i));
end
I haven't checked the code, so I might be wrong.
Thank you!