Creating multiplayer teams with different roles

first, set up a game mode that allows the player to respawn:

then, in the respawn code, inside the game mode, you can get the PlayerArray from your custom GameState, get the length of that array, then get a random integer between 0 and the array length. then foreach element in the playerarray, you can branch if the array index is equal to that random number, and if it is equal, spawn a different pawn to posses.

this special pawn can have different controls and spawn a different widget for its hud.

the problem with this method, is that you might have players joining or leaving the game, and you may only want to choose the random player at the beginning of the match, so maybe instead of checking the index of the PlayerArray, you should have a boolean variable in the player controller to keep track of which player is the chosen one.