I think I understand what you're wanting, here is a snippet of code . PHP: //$npc MUST be an entity.//$p MUST be an player//the code here would be used on PlayerMoveEventif($p->getLevel() !== $npc->getLevel()){ return; //we dont want to execute useless code that would slow the server down even more}$minDistance = 2; //distance a player must be before "entity" starts talking to them$distance = round($p->distance($npc)); //we are rounding the number because the distance could be a decimal and a player would be spammedif($distance > $minDistance){ return; //the player is too far away}//your code here