This Scripts goal is to EVENLY divide plays between two teams at the start of the round, the issue is, the timer runs fine, but the players do not change teams.
--Round Variables
local timeint = 10 --Numbers read as seconds
local inttime = 10 --Numbers read as seconds
local requiredplayers = 2
--Round Objects
local status = game.ReplicatedStorage.Status
local teams = {"Red","Blue"}
--Assign Teams
function getPlayersOnTeam(teamColor)
local players = {}
for _, p in pairs(game.Players:GetPlayers()) do
if p.TeamColor == BrickColor.new(teamColor) then
table.insert(players, p)
end
end
return players
end
function getSmallestTeam(teams)
local numPlayers, smallestTeam = math.huge
for team, players in pairs(teams) do
if #players < numPlayers then
numPlayers = #players
smallestTeam = team
end
end
return smallestTeam
end
function Assign()
local Red = getPlayersOnTeam("Bright red")
local Blue = getPlayersOnTeam("Bright blue")
local smallestTeam = getSmallestTeam({
["Bright red"] = Red,
["Bright blue"] = Blue
})
end
--Main
while wait() do
for i=inttime,1,-1 do
wait(1)
status.Value = "Intermission: "..i
end
Assign()
for i=timeint,1,-1 do
wait(1)
status.Value = "Time Left: "..i
end
end
Thanks
