I'm a bit new to Tables, and utilizing them. I've got a few questions. First of all, I want my script to check if a table is empty or not. Here is the code I have so far:
--I want this to check if the redTeam is dead, or if both the green AND blue team are BOTH dead.
if redTeam == "" then
--code
elseif greenTeam == "" and blueteam == "" then
--code
end
And my second question, how would I remove a player from a table if he dies? My attempted code:
function playerDied(humanoid)
local player = humanoid.Parent.Parent
if redTeam[player] then
table.remove(redTeam,player)
elseif greenTeam[player] then
table.remove(greenTeam,player)
elseif blueTeam[player] then
table.remove(blueTeam,player)
else
end
end
Also, would the following efficiently call playerDied?
while true do
for i,v in pairs(game.Players:GetChildren()) do
v.Character:WaitForChild("Humanoid").Died:connect(playerDied)
end
wait()
end

3 comments
Your answer to my first question just states how to print the table's value. How could I check if it was empty?
Oh. I actually don't know you could do local numInTab = 0 for i = 1,#RedTeam do print(RedTeam[i].Name) numInTab = numInTab + 1 end if numInTab == 0 then print("No one in table") end
Yeah ^ That should work! Sorry for the confusion.