if a player leaves (for example Player2), how do i make the table delete the array "Player2" after Player 2 leaves from the game?
i'm baffled and this is all i could do right now:
players = {}
local function onCharacterAdded(chr)
table.insert(players, chr)
local value = players[math.random(1,#players)]
print(value)
end
local function onCharacterRemoved(removed)
table.remove(players, removed)
end
game.Players.PlayerAdded:Connect(onCharacterAdded)
game.Players.PlayerRemoving:Connect(onCharacterRemoved)
while true do
wait(2)
print(players[1])
print(players[2])
end
