Best Way To Track Something In Table

I Have A playerTable Here And I Want To Fire A Function. But Only If The Plr Is In The Table. Anyway to track that?

game.Players.PlayerRemoving:Connect(function(plr)
	if playersTable:FindFirstChild(plr) then
		Remove(plr)
	end
end)

You can use table.find(t, v). It returns the index of v in table t, returns nil otherwise.

local i = table.find(playersTable, plr)

if i then
    table.remove(playersTable, i)
end
2 Likes