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

Putting all players into one team?

Asked by 9 years ago

Okay, so I'm making a game where I want all players to be put in a team, and after they die they go back into the lobby. (Neutral, if I have to make another team for the dead that's ok.)

So, how would I put all current players into one team?

Would I grab all the players and then add something like TeamColor == "Medium stone grey"?

Please help.

2 answers

Log in to vote
2
Answered by
rexbit 707 Moderation Voter
9 years ago

To place more information in Hungryjaffer's answer, Use the pairs function to access all of the players, the pairs function iterates through the Players container making it all one value.

for _,players in pairs(game.Players:GetPlayers()) do
    players.TeamColor = BrickColor.new("Medium stone grey")
end
1
Testing this, thanks for the help! iiDitzy 5 — 9y
Ad
Log in to vote
3
Answered by 9 years ago
for _,v in pairs (game.Players:GetPlayers()) do -- Get all players
v.TeamColor = BrickColor.new("Medium stone grey") -- Change all their teams to Medium Stone Grey
end -- Ending.
1
I feel like this is missing something. HungryJaffer 1246 — 9y
1
No, it looks perfect actually. An explanation might help him understand this better, but other than that the code is fine. Upvoted :p dyler3 1510 — 9y
0
Nothing is missing, except the main values: Explain your code, what is the pairs function?, How does it work?. rexbit 707 — 9y

Answer this question