Method 1:
while true do
task.wait(0.25)
for _, plr in pairs (Players:GetPlayers()) do
-- do thing on player
end
end
Method 2:
local playerCache = {}
Players.PlayerAdded:Connect(function(plr)
table.insert(playerCache, plr)
end)
while true do
task.wait(0.25)
for _, player in pairs (playerCache) do
-- do thing on player
end
end
Which is more performant?
At maximum, there will be 20 players.
For method 2, I can replace the in pairs loop with a for i loop.