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

Best ways to change a players team color?[unanswered]

Basically what I am attempting to do is create a function(set after other functions in the script) and use it to change everybodys' team color to blue. Unfortunately, the method I have been using seems to affect only the first person to enter the server.

for i,v in pairs(game.Players:GetPlayers()) do
v.TeamColor = BrickColor.new("Bright blue")--This is the team I want it to change to.

If you are wonder this Is in a function so it does run.

So I have two questions that depend on the answers of eachother.

  1. Why did it only change the team color of the first person to enter.

  2. If there is no apparent reason or it is simply the script, are there any alternatives I can use to fix it? I appreciate you help!

3 answers

✓ Accepted answer

Well, this may help you. It will check what the Players are in the Game, then choose them to become the color, ("Bright blue")

 play = game.Players:GetChildren()
for i = 1, #play do 
if play[i]~= nil then
play[i].TeamColor = BrickColor.new("Bright blue")
end
end
print("Blue Team")
 wait(0.1)

1 comment

0

Trying it out now.

Im not sure why you want to change everyone's teamcolor through a script. You can go to the teams, and uncheck "Autojoin:" in every team except the blue team. If that is not the way you want it for some reason, Im going to need the entire function.

3 comments

0

I see what you mean . No basically the function ends the round by removing the map for a second(killing the player) then(since some players team color becomes bright orange throughout the game) changes their team color back to blue. Do you still want the full function.

0

Hmm, im not sure why this doesn't work then. If you have built this kind of game it seems like you are a better scripter than me. Maybe someone else can help you.

0

Alright thanks for your time. I appreciate it.

function SetTeam(Color)
	for i,v in pairs(game.Players:GetChildren()) do
		v.TeamColor=BrickColor.new(Color)
	end
end

SetTeam("Bright blue")

1 comment

0

The same thing happens with all of these it must be another part of the script. I'll work on it

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