How do i make a script that counts the amount of players? (read desc)

how do i make a script that counts the amount of players in your game and if you have more than the number you need/want then the round/game runs. For example, there is 3 players and there needs to be 5 players to get teleported into the new round but it can’t cause there is only 3 players… 2 min later 6 players are in the game and now the game will teleport the players to the new round.

local num = game.Players:GetPlayers()

if #num >= 5 then
    --do stuff
end
``

ok thanks for the script i look through youtube and couldn’t find anything

also how do you make it so the script teleports all players to the part?

local players = game.Players:GetPlayers() --gets a table of all the players
local part = --e.g. workspace.Part

for _, v in pairs(players) do --loops through all the players
    v.Character:MoveTo(part.Position) --moves the players to the position of the part
end

if the player is dead, then this could error.

local players = game.Players:GetPlayers() --gets a table of all the players
local part = --e.g. workspace.Part

for _, v in pairs(players) do --loops through all the players
    if workspace:FindFirstChild(v.Character) then
       if v.Character:FindFirstChild("HumanoidRootPart") then
           v.Character:MoveTo(part.Position) --moves the players to the position of the part
       end
    end
end

to simply get the number of players, do this

local amntofplayers = #game.Players:GetPlayers()