GetOnlinePlayers() does not return an indexed array
This won't work because the array returned by GetOnlinePlayers() is not an indexed array, but an associative array with the players rawUUID as the key:
Also, your function needs to return an array with the name of the player, not the Player object.
Deleting a branch is permanent. It CANNOT be undone. Continue?