I'm trying to make a game like darkness just don't know how to make the script choose someone at random
COMMUNITY QUESTION
How do you I get team color to choose a person at random for a certain team?
1 answer
For this you'll need a basic understanding of tables and the math.random function. Here's a quick rundown:
local players = game.Players:GetPlayers() -- Get a table of all of the players in the game
local randomIndex = math.random(#players) -- Choose a number from 1 to the number of players
local randomPlayer = players[randomIndex] -- Get the player at the index "randomIndex"
-- randomPlayer is now a randomly selected player
This discussion is preserved as it was. New answers, comments, and votes are closed.
