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

Picking a player from all players?

Asked by 4 years ago
Edited 4 years ago

So , i'm trying to make a script that picks a player then picks another player. local nF = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]

rest of the code

   `while wait() do
    progress = true
    print(nF.Name)
        for i =intime , 0, -1 do
            wait(1)
            text.Text = i
        end
        nF.TeamColor = game.Teams["Monster"].TeamColor
        nF.Character.HumanoidRootPart.CFrame = workspace.NeighborSpawn1.CFrame
        `
        `for i =round , 0, -1 do
            wait(1)
            roundtime.Text = i
        end
        for _,players in pairs(game.Players:GetPlayers()) do
            players.TeamColor = game.Teams["Lobby"].TeamColor
            players.Character.HumanoidRootPart.CFrame =         workspace.SpawnLocation.CFrame
        end`

1 answer

Log in to vote
1
Answered by 4 years ago

GetPlayers will return a table of all the players, it essentially comes down to just picking a random value in a table.

local RandomPlayer = Players:GetPlayers()[math.random(#Players:GetPlayers())]
0
Thanks , it worked DragosGames 43 — 4y
0
Make sure to click answered on my answer when it's all good. Nickuhhhhhhhhhhhhhhh 834 — 4y
0
Ummm , how , cuz i don't see any button DragosGames 43 — 4y
Ad

Answer this question