First we use a for loop to get the players. We use an if statement to see if the player is on a team, then we just use their names.
For Loops
They just loop for a certain amount of time.
You can also do this:
1 | for _,plyr in pairs (game:GetService( "Players" ):GetPlayers()) do |
If Statments
It's basically just saying, "If something happens do this:"
2 | print ( "Bob is a human" ) |
Names and adding them to strings.
1 | hint.Text = game:GetService( "Players" ).Player 1. Name |
Hint says:
Player1
TeamColors are BrickColors. So to see if they're on a team, see if they're TeamColor is a certain BrickColor:
1 | game:GetService( "Players" ).Player 1. TeamColor = BrickColor.new( 127 ) |
01 | local h = Instance.new( "Hint" , workspace) |
03 | for _,plyr in pairs (game:GetService( "Players" ):GetPlayers()) do |
04 | if plyr.TeamColor = = BrickColor.new( "Bright red" ) then |
05 | h.Text = "Players on the Red team: " |
06 | h.Text = h.Text..plyr.Name |
Hope this helps!