here is what I have so far
function sortTeams() local Players = game.Players:GetPlayers() local lobbyPlayers = game,Teams.NotinGame:GetPlayers()
I seem to have hit a roadblock and cant figure it out. Thanks!
here is what I have so far
function sortTeams() local Players = game.Players:GetPlayers() local lobbyPlayers = game,Teams.NotinGame:GetPlayers()
I seem to have hit a roadblock and cant figure it out. Thanks!
--###----------[[SERVICES]]----------###--
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
--###----------[[VARIABLES]]----------###--
local LobbyTeam = Teams.NotInGame
--###----------[[FUNCTIONS]]----------###--
local function GetSortedLobby()
if ((#LobbyTeam % 2) ~= 0) then return end
--[[
^ Ensures that the original array is of even elements,
remove to allow odd sorting.
Ceil gives a bias to Team 1, Floor, Team 2.
]]
---------------
local SortedTeams = {
{},
{};
}
---------------
for _, Player in pairs(LobbyTeam) do
---------------
if (#SortedTeams[1] < (math.ceil(#LobbyTeam / 2))) then
---------------
table.insert(SortedTeams[1], Player)
else
table.insert(SortedTeams[2], Player)
end
end
---------------
return SortedTeams
end
hey, Thanks for asnswering!
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Please put the code in a code block :)