Дело в том, что функция GetPlayerHeroes сама возвращает массив, поэтому значение полей массива heroes со 2 по 5 — nil, а первое — table. То же самое относится и к самой таблице "hero", поэтому в вашем случае и IsHeroAlive(hero) и IsHeroAlive(hero[k]) будут ломаться — с указанной вами ошибкой.
Поэтому нужно в локальный массив heroes скинуть таблицу из функции GetPlayerHeroes, потом пройтись по массиву с указанными действиями и всё.
function incom()
local day = GetDate(3)
if day == 2 then
local heroes = GetPlayerHeroes(5)
for k, hero in heroes do
if IsHeroAlive(hero)
then
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types[i])
then
local stack = GetCreatureById(types[i]) --Если вы копировали из RW, то, надеюсь, скопировали и функцию GetCreatureByld.
local amount = GetHeroCreatures(hero, types[i])
AddHeroCreatures(hero, types[i], amount, i)
end
end
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")