You wrote a function, but you didn't specify what should trigger it...
For example, startThread, outside the function.
The second problem is that your function will only run once. To make the game constantly check something, add a loop inside, an infinite loop:
while 1 do
end;
But don't forget to add a sleep function, otherwise the game will freeze.
From level 3? You wrote that it starts from level 1... I don't understand...
Only for one hero? It would be better to search for all stronghold heroes on the map. Also, there's a problem: if that hero dies, the function will crash with an error. You need to check IsHeroAlive.
And ideally, add a break after the skill is acquired, to exit the loop.
If the goal is to wait for the hero to reach level 3, you can use a Trigger instead of an infinite loop, as there seems to be a level-up condition there. Take a look.
P.S. Yes, scripts are like that. What did you expect? )
I specified level 3 in the function specifically to test whether it works or not. And it will be easy to change it to the desired level later.
And for now, I decided to implement it for one hero - after all, it's just a test.)
And after a successful test, I'll specify the hero's race in the function instead of the name.
Thank you for pointing it out - I'll try to implement it according to your suggestions.