- Create a normal Script in ServerScriptService.
- Write this code in it:
local players = game:GetService("Players") -- Get Players service
local function startRound() -- startRound function
local possiblePlayers = players:GetPlayers() -- Get all the players in the server and put them in a table
local catcher = possiblePlayers[math.random(1, #possiblePlayers)] -- Select a random player to be the catcher
table.remove(possiblePlayers, catcher) -- Remove the catcher from the possible players to choose from
local runner = possiblePlayers[math.random(1, #possiblePlayers)] -- Select a random player to be the runner
table.remove(possiblePlayers, runner) -- Remove the runner from the possible players to choose from
-- Do what you will with the catcher and runner
end
startRound()
-
Now, whenever you call
startRound()
, it will select a catcher and a runner, and you can add on to the function to do whatever you want with the catcher and runner. -
(optional) If you want to loop the
startRound()
function over and over again, add this to the script:
while true do -- Forever loop
startRound() -- Start round
task.wait(180) -- Replace 180 with however many seconds you want in between rounds
end