Someone could help me please?

I need a action that check if some player is attacking you "then go to" label.

I will create a afk script in front of my house training with a monk to go inside the house and logout when a PK appears.

Thanks.