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

How to change a players team?

game.Players.TeamColor = "Bright blue";

This dosent work. i have an event before it to pick a teams, but I need it then to make it check to see if the Players is on red, then puts their teamcolor to red.

	players = game.Players:GetChildren()
	randomp = players[math.random(#players)]
	print(randomp.Name .. " is killer")
	game.Player.TeamColor = BrickColor.new("Bright red")
	for i,v in pairs(players)  do
		if v.Name ~= randomp.Name then
      		print(v.Name .. " is runner")
			game.Player.TeamColor = BrickColor.new("Bright blue")
		end
	end

4 comments

0

TeamColor is a property of 'Player', so that wouldn't work. Also TeamColor has to be a BrickColor, so you would put game.Player.TeamColor = BrickColor.new("Bright blue"). I'm not entirely sure on what you're asking, could you clarify?

0

Ok so I have this thing that picks 1 random player to be a killer and the rest are runners. I need it so once the killer has been chsoen they get put on red team and the rest of blue team

0

Also their is no Player in game. game.Player won't work, it has to be Players, dosen it?

0

I have editted to show the whole script

1 answer

✓ Accepted answer

Player is never defined, replace Player in line 4

game:GetService("Players"):FindFirstChild(randomp).TeamColor = BrickColor.new("Bright red")

This looks through the Players and finds the player under the variable randomp then changes their teamcolor

and on line 8 replace what you have with

v.TeamColor = BrickColor.new("Bright blue")

as v represents each member of the table, and the table consists of all the players.

1 comment

0

Still dosent work?

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