Remove character from table when player leaves?
So I am trying so hard to make this work. Here's the situation:
When the player enters a sort of area, they are added to a table of players waiting for intermission. However, if a player gets added to the table, and then leaves the next time the game tries running a round the server will send an event to every player that is in that table. The problem is, I can't remove the player from the table when they leave, so the server tries finding that player (since they are still in the table) but can't because they don't actually exist.
Here is some code:
01 | local function interm(player) |
03 | if player.inInterm.Value = = false then |
04 | player.inInterm.Value = true |
05 | table.insert(playerInterm, player) |
10 | script.Parent.Touched:Connect( function (hit) |
12 | if game.Players:GetPlayerFromCharacter(hit.Parent) then |
13 | if hit.Parent:FindFirstChild( 'inInterm' ) then |
16 | if #playerInterm ~ = 0 then |
17 | script.Parent.start:Fire() |
Script the gives error:
1 | for i, v in pairs (playerInterm) do |
2 | Blur:FireClient(game.Players [ v.Name ] ) |
For your information, it's the character that gets added to the table. I don't want to change that because it is to complex because of all the other scripts that rely on this. I can't seem to find anyway to remove the character from the table when the player leaves...