Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Table remove is not removing the player from the table?

So I created a table and it adds players names into it, but I want it to remove the player names when the player leaves, so I tried using table.remove:

activePlayers ={}

-- adds players to table if they join server

game.Players.PlayerRemoving:Connect(function(player)
	for i, v in pairs(activePlayers)do
		if v == player.Name then
			print("user removed")
			table.remove(activePlayers, i)
		else

		end
	end
end)

I am not sure why this is not working because I tried to remove the value for that player, but I'm not sure how to get rid of the player from my table.

1 comment

0

Would I have to do on line 7: if tostring(v) == player.Name then

1 answer

✓ Accepted answer

I was going to try to help you fix your code, but then I realised that you are trying to make a function that already exists.

1 comment

0

So would I just do in the joined function to get players and in the player removed function to get players?

This discussion is preserved as it was. New answers, comments, and votes are closed.