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?

i have a script that selects one person to be a killer and the rest to be runners. I need it so once the killer has been selected it changes their team to bright red and once the runners have been selected to change their team to bright blue.

Script That needs editing:

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

1 answer

✓ Accepted answer

This code is okay, but the only thing that goes wrong is setting the TeamColor. TeamColor is a BrickColor and should therefore receive a BrickColor:

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.Players.TeamColor = BrickColor.new("Bright blue");
        end
end

2 comments

0

dosent work

0

Are you using ONLY this code or have you incorporated this somewhere? Is this a server script? Is there output which says " is killer" ?

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