Using the operator "#" in a for loop (pairs)

So currently what im doing is trying to get the players, then get the number of players by using the operator “#”. However i’m always met with the following error

ServerScriptService.RoundHandler:29: attempt to get length of a Instance value

Here’s what i’m doing

for i,v in pairs(players:GetPlayers()) do

how would i go about setting this up?

You have the right idea, but it’ll take a little more work to actually work.

local activePlayers = players:GetPlayers()
local numPlayers = #activePlayers

for i, v in pairs(activePlayers) do
     print(i, v)

All you need for the number is this:
When you use GetPlayers() it returns a table {} of Player instances as an array.
So to loop through the instances you would:

for index, player in players:GetPlayers() do
    print("position in array:", index)
    print("player instance:", player)