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

How could I fix my place player in team script?

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

✓ Accepted answer

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

1 comment

0

It's working! Thanks for the help!

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