Scrip that triggers on change to any different queue

I might be missing an obvious solution so let me know. I’d like to write a scrip that triggers on a change out to any other queue, but I’m struggling to get the condition correct. Specifically:

If I’m moving things from Queue A to Queue B, “On Queue Change” only triggers when things are moved into Queue A. How do I put a scrip on Queue A so that I know anytime a ticket is moved out of the queue? What I’m doing is making a scrip that sends “Ticket 123456 moved to queue Queue B”. I have the action all together, but can’t get it to fire at the right time.

I’ve tried some custom conditions and tinkered around, but I’m stuck, because the Queue change seems to shift the focus to the new queue and I can’t get the condition correct on User Defined.

Example what I’ve tried, that doesn’t work because the scrip is on Queue A:
if ( $TicketObj->QueueObj->Name ne “Queue A” )
{
return 1;
} else {
return 0;
}

Thank you!

The only thing I can think of is to have a global scrip (ie applied to all queues) that checks if the transaction was a queue change and if so, if the old value of the queue was “Queue A”.

Yes, that makes more sense now, that the scrip is processing after the ticket is out of the queue. Thank you!