How do I remove the player from the table when they left, when ever I run the game I keep getting the error.
gameTable.removeImposter = function(removeThisPlayer)
for i, players in pairs(gameTable.imposters) do
if players == removeThisPlayer then
table.remove(gameTable.imposters, i)
end
end
end
players.PlayerRemoving:Connect(function(plr)
if table.find(imposters, plr) then
removeImposter(plr)
print(imposters)
end
end)
It means the code in the function isn’t working then. Also you are printing the table before you are removing. If you want to see the player removed, try printing the table after you have removed the specific player.
I did that so that I would know that they are inside the table, and here is the script for the function:
gameTable.removeImposter = function(removeThisPlayer)
for i, players in pairs(gameTable.imposters) do
if players == removeThisPlayer then
table.remove(gameTable.imposters, i)
end
end
end