Connection ErrorBad RequestThis page went staleSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
This page went stale
Your security token was rejected, usually because the page sat open too long or you signed in elsewhere. Nothing was saved. Reload the page and try again.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
The thing is, the GetPlayerHeroes function itself returns an array, so the values of the array fields "heroes" from 2 to 5 are nil, and the first one is a table. The same applies to the "hero" table itself, so in your case, both IsHeroAlive(hero) and IsHeroAlive(hero[k]) will fail – with the error you specified.
Therefore, you need to copy the table from the GetPlayerHeroes function into a local array called "heroes," then iterate through the array and perform the specified actions.
```lua
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]) -- If you copied this from RW, I hope you also copied the GetCreatureById function.
local amount = GetHeroCreatures(hero, types[i])
AddHeroCreatures(hero, types[i], amount, i)
end
end
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")