The first 2 lines are related to p3heroname, and the combat script is attached and the combat is launched for the hero named p1heroname. Does the hero p1heroname actually exist?
Update: I opened your map, checked the script, and p1heroname is not mentioned anywhere. So, the question from our (somehow silent in this case) script is: "Who is this p1heroname of yours?!"
p3heroname = GetPlayerHeroes(3)[0];
print(p3heroname);These 2 lines are only for checking if the game can see the 3rd player's AI hero correctly. They can be commented out, and nothing will change. Also, I inserted this same piece of code into other tests, where the teleport function works through interaction with a skeleton on the map. The result is the same. Now I've moved it to the main MapScript.lua file to quickly check if it works or not. Otherwise, it will be located separately, and it will take a long time to get to it on the map for it to trigger.
I want to attach the combat script to the player's hero, not the AI's. That's why I'm attaching it to p1heroname.
If there is a logical error somewhere, I admit that Lua is very specific. I only have residual knowledge of programming from university).
By the way, I remembered a question: why can't you edit xdb files through MapScriptsEditor?