Skip to content

GetLocalHero()

GetLocalHero(): Hero | null

Description

The GetLocalHero function returns the player's local hero. If the local hero does not exist, the function returns null.

Returned

  • Hero - hero object representing the player's local hero.
  • null - if local hero is not exists.

Example

ts
let exampleScript: ScriptDescription = {};

exampleScript.OnScriptLoad = () => {
	let myHero = EntitySystem.GetLocalHero();
	if(myHero) {
		console.log("My hero name - ", myHero.GetUnitName());
	} else {
		console.log("Local hero not found");
    }
}

RegisterScript(exampleScript, "Example script");