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

Picking a player from all players?

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

✓ Accepted answer

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())]

3 comments

0

Thanks , it worked

0

Make sure to click answered on my answer when it's all good.

0

Ummm , how , cuz i don't see any button

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