Okay, so here's my script:
playerCount = {}
Players = Game:GetService("Players")
Players.PlayerAdded:connect(function(Player)
table.insert(playerCount, Player.Name)
print(table.concat(playerCount, ", "))
end)
Players.PlayerRemoving:connect(function(Player)
table.remove(playerCount, Player.Name)
print (table.concat(playerCount, ", "))
end)
Now, as you can see, if I have two players enter, and then have one leave, the table.remove event cause an error, because I have to have a number instead of Player.Name. If you can see what i was trying to do, I was trying to remove the player's name out of the table playerCount. But of course, you can't do it like that. You would have the number of where the player's name inside the table would be and replace Player.Name with that number.
So, I was wondering, how would you find the number of where the player's name is, so I could remove it whenever they left?
(I am sorry if this isn't that descriptive or anything. I'm just having a hard time explaining this, and hope you can understand well.)

3 comments
Wait, so where in my script would i enter this into?
Wherever you're trying to remove the value from the table. That seems to be the PlayerRemoving event.
Oh, wait nvm