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

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

Asked by
wjs3456 90
10 years ago

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

Log in to vote
-1
Answered by
Yeevivor4 155
10 years ago

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)
0
Trying it out now. wjs3456 90 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

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.

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. wjs3456 90 — 10y
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. PureDefiance 20 — 10y
0
Alright thanks for your time. I appreciate it. wjs3456 90 — 10y
Log in to vote
1
Answered by
Muoshuu 580 Moderation Voter
10 years ago
function SetTeam(Color)
    for i,v in pairs(game.Players:GetChildren()) do
        v.TeamColor=BrickColor.new(Color)
    end
end

SetTeam("Bright blue")
0
The same thing happens with all of these it must be another part of the script. I'll work on it wjs3456 90 — 10y

Answer this question