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

What are the different ways to create a list of the players on a certain team?

Asked by 8 years ago

Read above. :). I'm looking for different ways so I can choose the one that works best for me. Thank you!

1 answer

Log in to vote
1
Answered by 8 years ago

Use game.Players:GetChildren(), run a check to see which team they're in, then use table.insert() to put their name/player in the Team's table. Beforehand, create X tables, for how many teams there are.

Example:

local blueTeam = {}
local redTeam = {}

while true do
    wait(30)
    local p = game.Players:GetChildren()
    for i = 1,#p do
        if p[i].TeamColor == game.Teams.RedTeam.TeamColor then
            table.insert(redTeam,p.Name)
        elseif p[i].TeamColor == game.Teams.BlueTeam.TeamColor then
            table.insert(blueTeam,p.Name)
        end
    end
wait()
0
Thank you. Ethan_Waike 156 — 8y
Ad

Answer this question