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:
local function interm(player)
spawn(function()
if player.inInterm.Value == false then
player.inInterm.Value = true
table.insert(playerInterm, player)
end
end)
end
script.Parent.Touched:Connect(function(hit)
pcall(function()
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if hit.Parent:FindFirstChild('inInterm') then
interm(p.Parent)
if #playerInterm ~= 0 then
script.Parent.start:Fire()
end
end
end
end)
end)
Script the gives error:
for i, v in pairs(playerInterm) do -- it tries firing this event to all players in the table. but some dont exist!!
Blur:FireClient(game.Players[v.Name])
end
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...

3 comments
Wow
this is very inefficient and it will still error from time to time.
if you do have anything better then please share it with me