Okay, so i want to pick 3 random players, but only from a certain team. So instead of using
local players = game.Players:GetPlayers() math.Random(3 , #players)
what would i use so it is limited to a certain team?
In the future, please make an attempt at what you intend to do. Otherwise your post might get locked for not being constructive.
What the GetPlayers function does not do is give you specific teams. However, there is an easy way around this. We could have a separate function that can return the players on a specific team though. What we want to do is establish the function and use a for loop to go through all players in the Players Service.
function GetTeamMembers() --We establish the function GetTeamMembers here. local PlayersOnTeam = {} --An empty table currently that we can add onto if someone is on the team. for _,v in pairs(game.Players:GetPlayers()) do --For everyone in the game, we want to do something to them. if v.TeamColor == BrickColor.new('Bright red') then --Change bright red to the team you want to gather players from. table.insert(PlayersOnTeam,v) --v is the player. We're adding the physical player to the table "PlayersOnTeam".= end end return PlayersOnTeam --Once the script has gone through all the players and checked to see if they were on the team, we can return the script to where it was with the table of players. end RandomUnluckyGuy = GetTeamMembers()[math.random(#GetTeamMembers())]
You would basically put the players from a specific team in a table. I'll let you figure out how to do it.
Hint http://wiki.roblox.com/index.php?title=Table
Then you would apply the random function to that table.