How do I make a console command take a player as an argument?

For example, if I want to make a command called getmoney, and make it take an argument that is the player, so if I type getmoney ‘player’s name’ then it would tell me how much that player has. in DarkRP.



concommand.Add("getmoney", function( ply, cmd, args ) 
   if( !IsValid( ply ) ) then return end 
   local name = args[1]
   local found = NULL
   for k,v in pairs( player.GetAll() ) do 
      if( string.find( v:Name(), name ) != nil ) then 
         found = v 
         break
      end
   end 
   if( IsValid( found )) then 
        print( (found == ply) and "$0 otherwise I would be on ScriptFodder" or found:GetDarkRPmonies() )
   end 
end  )


bad argument #2 to ‘find’ (string expected, got nil)

What did you type?