Currently, I have the game set so that every player has a "Spectator" value inside their player. What I'm trying to do is make it so that the game checks how many players are in the game. Sadly, I have no clue how to do this. I know a tiny bit about arrays and tables, but how do I make the game constantly check how many players are left in the game?
my current attempt:
while true do
plrs = game.Players:GetPlayers()
print(#plrs)
for i=1, #plrs do
if plrs[1].spect == true then
table.remove(plrs[1])
elseif plrs[2].spect == true then
table.remove(plrs[2])
elseif plrs[3].spect == true then
table.remove(plrs[3])
elseif plrs[4].spect == true then
table.remove(plrs[4])
elseif plrs[5].spect == true then
table.remove(plrs[5])
elseif plrs[6].spect == true then
table.remove(plrs[6])
elseif plrs[7].spect == true then
table.remove(plrs[7])
elseif plrs[8].spect == true then
table.remove(plrs[8])
elseif plrs[9].spect == true then
table.remove(plrs[9])
elseif plrs[10].spect == true then
table.remove(plrs[10])
end
end
wait(0.01)
end

1 comment
This is not a request site! Learn more lua / look up topics in youtube / ROBLOX wiki and then you can come here at scriptinghelpers.org for help if it doesn't work or you are just curious about something.