I know Whonix has a virtual machine that connects to the gateway which is like a router that sends everything into Tor. How could I make a gateway like that so I can connect a VM(like workstation) to it and it will send the traffic through Tor. Also how will I set the other VM(workstation one) to the gateway VM? I will be using Virtualbox.
There are multiple correct answers to a question like this because its vauge. If you want a whonix copy why not use whonix? One other easy way to build a gateway would be to download the openwrt x86 iso and install it to its own virtual machine, then install and configure tor as a transparent proxy, then configure your networking to use the interfaces on that machine for outgoing Internet access.
You could also do it with debian, or tails or liberte linux distros which are preconfigured with a lot of things you'd want.
Sorry I did not understand your question at first. You should be able to run other operating systems with a whonix gateway. You will just need to configure the network connection of the workstation. I would boot up the workstation that comes with whonix and look at the network configuration and use those same settings on the workstation of your choice.
Once you have the connection information for the whonix workstation, you can just add one digit to the last octet of the ipaddress of the whonix workstation and have both running at the same time. That will make it easier to go back and forth for testing until you are happy with the workstation you are setting up.
There are known problems using Microsoft operating systems and leaking information over tor, just so you know. Good luck