Minecraft – How to get this setup to work properly

minecraft-java-editionminecraft-redstone

I have a setup in a space-station with which I want an airlock with two doors: door X & door Y.

I've remade this setup in the Overworld in a smaller fashion to show you how I've got it set up which you can see here:

Door circuit

Before clicking the button (which is located on the back of the gold block behind the pistons), door X is open and door Y is closed, just making sure you don't confuse them :P)

This is supposed to close door X before opening door Y, after which it closes door Y before opening door X.

Although now it's closing door X, a few ticks later it opens door Y, but then it switches them around just about simultaneously again.

I've tried using a T-flip flop instead of this configuration, but that proves to be a bit too laggy on a multiplayer server (the doors bugged out by opening & closing repeatedly even though I only had a single pulse as input)

How can I get this to work as intended without using up TOO much space?

Update: I just thought of another possibility, which is making the button work like a lever (in my case by using pistons) and having 2 seperate outputs which are being toggled with different timings on each output, which works perfectly.

Now another question arises, if this is the way to do this, how do i get it to repeat itself once (so it works exactly the way I want it) without having to press the button again?

New circuit

Best Answer

Figured it out after a while & had some help from @SevenSidedDie for having the circuit repeat itself once & only once per button press :)

Uploaded a video of the circuit & it's operation.

Thanks to everyone for giving a hand at solving this (or at least trying :) )

Video: