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

How to change a players team?

Asked by 10 years ago
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
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? infalliblelemon 145 — 10y
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 NinjoOnline 1146 — 10y
0
Also their is no Player in game. game.Player won't work, it has to be Players, dosen it? NinjoOnline 1146 — 10y
0
I have editted to show the whole script NinjoOnline 1146 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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.

0
Still dosent work? NinjoOnline 1146 — 10y
Ad

Answer this question