How can I make a player randomizer?

I want to make a player randomizer like in hide and seek. One player becomes a seeker, and all the others become a hider.

I have next to no idea how to do this, but I will list the basis of the script.

local Players = game:GetService(“Players)”
if Players.Value == 10 then — making sure there are enough players
local chooser = num.Random

I go through all the numbers 1-10, and if the number is 1, Player.Team = hider and vice versa.
As I said, I am completely new to this, and that entire script could be wrong. Any help is appreciated! :smiley:

1 Like

Ooh, then the rest of the script should work, right?

Actually thats wrong since Players is a service, the strings are misplaced too.

Basically it would be this:

local Players = game:GetService("Players")
if #(Players:GetPlayers()) >= 10 then
local choosenPlr = Players:GetPlayers()[math.random(1, #Players:GetPlayers())]
end

Doing Players:GetPlayers() will return a table that has all the players inside.

Doing #Players:GetPlayers() will return the ammount of things inside that table (basically the ammount of players)

And that part of math.random is to search a random player that can be the first to the last.

2 Likes

Ooh, THEN I go on with the rest. Thanks soooo much!

oh, one thing. Should the "if chosenPlr == . . . " be IN the if statement, or after?

Just like how I did, (the Players.Value == 10 was remade to #(Players:GetPlayers()) >= 10)

Thanks! Doing the next statement outside of the if then statement told me that chosenPlr was an unknown global.