Hello,
So I am working on this script. My problem is that I need to check to see if there are any players left in the table. How this script works is if the players still has the value 'Playing' still set to true at the end of the game, it will add them to the table and display the name saying they have won. I need to keep checking to see if all players have died early in the round, not just at the end when it is over. If someone can see how you would do it, please do.
while true do
for i = 9,0,-1 do
syn1:FireAllClients('Intermission '..i)
wait(1)
end
syn1:FireAllClients('Choosing map.')
wait(1)
syn1:FireAllClients('Choosing map..')
wait(1)
syn1:FireAllClients('Choosing map...')
wait(1)
syn1:FireAllClients('Choosing map.')
wait(1)
syn1:FireAllClients('Choosing map..')
wait(.2)
local choosing = math.random(1,#maps)
local mapchosen = maps[choosing]
syn1:FireAllClients(mapchosen.Name)
wait(4)
clonemap = mapchosen:Clone()
clonemap.Parent = game.Workspace
syn1:FireAllClients(mapchosen.Instructions.Value)
wait(.5)
gtl = game.Players:GetChildren()
for i = 1,#gtl do
gtl[i].Playing.Value = true
end
wait(2)
spawns = clonemap.Spawns:GetChildren()
for i,v in pairs (game.Players:GetPlayers()) do
if v.Playing.Value == true then
v.Character.Torso.CFrame = CFrame.new(spawns[i].Position)
end
wait(.5)
for i = 4,0,-1 do
syn1:FireAllClients('The round will being in: '..i)
wait(1)
end
syn1:FireAllClients('Begin!')
wait(.8)
while true do
wait(.2)
end
for i = mapchosen.Roundtime.Value,0,-1 do
syn1:FireAllClients('The round will end: '..i)
wait(1)
end
syn1:FireAllClients('Time up!')
wait(2)
getllas = game.Players:GetPlayers()
for i=1, #getllas do
if getllas[i]:FindFirstChild("leaderstats") then
if getllas[i].Playing.Value == true then
getllas[i].leaderstats.Points.Value = getllas[i].leaderstats.Points.Value + 10
table.insert(winners, getllas[i].Name)
end
end
end
if #winners == 0 then
syn1:FireAllClients('No winners!')
else
syn1:FireAllClients(table.concat(winners, ", ").." Have won!")
wait(5)
end
end
end

1 comment
You should tab your code correctly.