I had been looking at the syntax, but not at what you're doing. This may fail if you're not already at that nick, if nickserv sees your password before the change nick happens. if that's a problem, you may need to introduce a delay after the /nick, using a timer and $unsafe. However, there's a good chance that newer nickserv lets you identify from any nick like "/nickserv identify accountname password", and nickserv uses your active nick only if you give it 3 words.
This variant halts the script if there's not a $2 word. If you want the nickchange to happen without a password, you can swap the last 2 commands

Code
alias F2 {
  if ($scid($cid).status != connected) { echo -ag you are not connected | return }
  tokenize 32 $$input(What's your nickname and password?,etd) 
  quote nickserv identify $1 $$2
  nick $1
}