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

How could I fix my place player in team script?

Asked by 7 years ago

So my script makes that if someone is in the team "Medium stone grey", they get placed in the team Cyan.. But It's not working, I dont know why.

Heres my script :

player = game.Players:GetChildren()
if player.TeamColor == BrickColor.new("Medium stone grey")
    then
        player.TeamColor = BrickColor.new("Cyan")
    end

Thanks for the help!

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You should loop through all players individualy, we can use a for loop for this. We also want a while loop because we want to check if a player is in the wrong team all the time.

While looping through the players we check if the player's team color is medium stone grey, if thats the case, we change it to cyan.

In code format, this looks like this.

while true do -- loop
wait(1) -- waits

  for _,player in pairs(game.Players:GetPlayers()) do -- Loop trough all players
    if player.TeamColor == BrickColor.new("Medium stone grey") then
       player.TeamColor = BrickColor.new("Cyan")
    end
  end
end

Any questions? comment below ;D

0
It's working! Thanks for the help! starchip12 6 — 7y
Ad

Answer this question