I'm making a game that involves rounds, so I'm trying to make it so the script only starts the round if there are 5 or more people in the game. If there isn't, I'd like to make it say "waiting for players...". The problem is, even if there are 5+ people, it still says "waiting for players". I can't figure out how to fix this script.
maps = {"Round"}
Positions = {}
Winners = {}
local Players = game:GetService('Players')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
intermission = 7
timebeforeroundstarts = 5
Roundwait = 6
function m(update)
local c = game.Players:GetChildren()
for i=1, #c do
c[i].PlayerGui.InformationGui.loltext.Text = "" .. update
end
end
while wait() do
if #Players:GetPlayers() >= 5 then
wait(1)
for i=1, intermission do
m("Intermission: " .. intermission - i)
else
m("Waiting for players...")
end
end)
gtl = game.Players:GetChildren()
for i=1, #gtl do
gtl[i].Playing.Value = true
end
mapnum = #maps
map = maps[mapnum]
game.Lighting[map]:Clone().Parent = workspace
m("Game Starting...")
wait(3)
m("Game Starting...")
wait(2)
for i=1, timebeforeroundstarts do
m("The game will start in: " .. timebeforeroundstarts -i)
wait(1)
end
getall = game.Players:GetChildren()
getspawns = game.Workspace[map].Spawns:GetChildren()
for i=1, #getall do
if getall[i].Playing.Value == true then
curspawn = game.Workspace[map].Spawns.Spawn
getall[i].Character.Torso.CFrame = CFrame.new(curspawn.Position)
curspawn:remove()
end
end
if map=="Round" then
for i=1, Roundwait do
m("The game will end In: " .. Roundwait -i)
wait(1)
end
end
getllas = game.Players:GetChildren()
for i=1, #getllas do
if getllas[i]:FindFirstChild("leaderstats") then
if getllas[i].Playing.Value == true then
getllas[i].leaderstats.Wins.Value = getllas[i].leaderstats.Wins.Value + 1
getllas[i].leaderstats.Points.Value = getllas[i].leaderstats.Points.Value + 10
table.insert(Winners, getllas[i].Name)
end
end
end
if #Winners == 0 then
m("Nobody Won!")
else
m(table.concat(Winners, ", ").." Has won!")
end
game.Workspace[map]:remove()
for i=1, #Winners do
table.remove(Winners, 1)
end
end
