How to create a Team System?

I want to be able to join the server, join a random team (A or B), spawn in the correct area, and play.

How can I go about this? Any tutorials, ideas or videos I should watch? I am brand new.

I made this serie of tutorials a while ago:

https://www.youtube.com/watch?v=SfD5…l&index=2&t=0s

It can be outdated and I’m sure I would cry watching some horrible things I’m doing in the code but eh, it’s a working tutorial anyway.