Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Putting all players into one team?

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

✓ Accepted answer

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 comment

1

Testing this, thanks for the help!

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.

3 comments

1

I feel like this is missing something.

1

No, it looks perfect actually. An explanation might help him understand this better, but other than that the code is fine. Upvoted :p

0

Nothing is missing, except the main values: Explain your code, what is the pairs function?, How does it work?.

This discussion is preserved as it was. New answers, comments, and votes are closed.