Basically I want to add players names to a table when they join and remove them when they leave. How do you search through the table and remove the players name when they leave. This is what I have so far.
listofaccounts = {}
function inTable(listofaccounts, item)
for key, value in pairs(listofaccounts) do
if value == item then return key end
end
return false
end
game.Players.PlayerAdded:connect(function(player)
local player1 = player.Name
table.insert(listofaccounts, player1)
end)
game.Players.PlayerRemoving:connect(function(player)
local player1 = player.Name
if listofaccounts[player.Name] then
table.remove(listofaccounts, inTable(listofaccounts, player.Name))
end
end)

1 comment
Thanks this is perfect and exactly what i was looking for. Couldn't have asked for a better answer.