local function pickPlayers(Holder,Template,ServerSize)
local players = players:GetPlayers()
local spare = ServerSize-#players
local open = {}
for i = 1,ServerSize do
local frame = Template:Clone()
frame.Name = "frame"..i
frame.Parent = Holder
open[i] = i
end
local function loop()
for i,player in pairs(players)do
local key = math.random(1,#open)
local value = open[key]
setPlayerToFrame(player,Holder:FindFirstChild("frame"..value))
open[key] = nil
for i=1,#open do
if open[i-1] == nil then
open[i-1] = open[i]
open[i] = nil
end
end
end
end
loop()
if spare > 0 then
repeat
loop()
spare -=#players
print(#open,open) -- This is the line I printed on
until
spare <=0
end
end
You would have to use a custom function, like this:
local function GetLength(table)
local counter = 0
for _,v in pairs(table) do
counter += 1
end
return counter
end
local array = {
1, 3, 5, 6, 8, 9, 10
}
local dictionary = {
[0] = 5,
[8] = 10,
[15] = 17,
[25] = 50
}
local function GetLength(table) -- this works for both arrays and dictionaries
local counter = 0
for _,v in pairs(table) do
counter += 1
end
return counter
end
warn(#array) -- 7
warn(#dictionary) -- 0
warn(GetLength(dictionary)) -- 4