Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script to pull two random players as team captains?

Asked by 7 years ago

I'm trying to integrate a script so that after a bit when a new game begins (I am making a Sports game) two team captains will be selected. I've looked into other questions regarding selecting a random player, but I have no idea how to select two, and give them the team selecting GUI.

I couldn't fit this into the title, but I'd also like to know how to have these team captains recieve a team selecting Gui I have already created.

Thank you for your time in advance!

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Get players from both teams, and store them inside of an array: http://wiki.roblox.com/index.php?title=API:Class/Team/GetPlayers

Pick a random player from the array:

#myArray -- length of myArray
math.random(x) -- random number from 1 to x
myArray[x] -- Xth element of myArray

myArray[math.random(#myArray)]
Ad

Answer this question