You're only checking the guard != null. To get started; you should also check if your player is not under attack, if the guard is not under attack and if the guard is still alive (not doing the death emote, cause then its still not null while performing the emote)