This random value could be combination of a value being a member of a certain scale, an offset in terms of key and an offset in terms of octaves. A major scale could be defined and stored as [zl lookup 0 2 4 5 7 9 11]. A [random 7] can generate an index producing a stored value. Add to this a fixed valeu (eg 2 to make it D major). Finally add a random value (eg [random 3] for random three octaves) plus an octave offset (eg 3) multiplied with 12 (add: 12 x (3 + random(3)).
The makenote in your patch between the random and nslider is not really required. Also the second inlet of makenote does not need a trigger from the metro.
Thanks for helping, i added a metro between the bang and the t b b, so it can trigger notes from specific scales regularly. The next step will be to build other scales and the interface, when i finish, i plan to build some recorder for the sequence generated in max and the sequence i play based on de generated sequence, so it can calculate my precision at the piano. Any tips?