I am making a game called Agent Blox which is based on Juggernaut but how to I make a script that chooses a random player to be in another team (classname) I think there is a way I could fix that but I don't know how to refer to a player in a script! game.Players.Player does not work. Please help!
How do I refer a player in a script?
3 answers
In the example I have done for you below, I start off with picking a variable for the TeamColor. Then I choose a random player by using math.random() with the minimum amount of players (1) to the number of players, which I can find by using "#game:GetService("Players"):GetPlayers()", or I could have done "game:GetService("Players").NumPlayers". Both work fine. Then I make that players TeamColor the BrickColor of the variable we provided earlier.
local TeamColor = "Really red"
local RandPlayer = game:GetService("Players"):GetPlayers()[1, #game:GetService("Players"):GetPlayers()]
RandPlayer.TeamColor = BrickColor.new(TeamColor)
local players = game.Players:GetChildren()
local log10 = math.random(1, #players)
players[log10].TeamColor = "Bright blue" -- Make Juggeranut team Bright blue
players[log10].Character:MoveTo(Vector3.new(0,0,0)) -- change 0,0,0 To a position the juggernaut will spawn.
PM Hybric if script doesn't work
2 comments
It's BrickColor.new("Bright blue") not just "Bright blue".
Also he never specified for the player to be moved.
This might not work but here you go.
game.Workspace.Players.Random = Random.Players
Probably try that in the script
4 comments
This is not correct at all.
Well you can be a bit nicer. I tried.
Don't post an answer if you have no idea what you're doing. That just spreads false information.
Well thanks for information you already told people. I tried so you should give me that. Stop jumping on people for false information. God.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You forgot the Workspace in between game.Players.
I have seen this question asked numerous times on SH, you should be able to search for the answer. Roboy5857's answer here is also wrong and to be ignored.