This is how I did it for my game:
First, put everything you want to store into an object. For me that was a whole bunch of things, but for you it's just $playerName and $currentScore.
<<set $hiscore = {
name: $playerName,
final_score: $currentScore
} >>
Then add it to the array. Here's the code from my game, slightly modified to store 10 hiscores rather than 100:
/* Create high score table if it doesn't exist */
<<if !$PERM_hiscores>>
<<remember $PERM_hiscores = []>>
<</if>>
/* Add new high score in appropriate place in table */
<<set _saved = false>>
<<for _n = 0; _n < $PERM_hiscores.length; _n++>>
<<if $hiscore.final_score >= $PERM_hiscores[_n].final_score>>
<<remember $PERM_hiscores.splice(_n, 0, $hiscore)>>
<<remember $PERM_most_recent_score = _n>>
<<set _saved = true>>
<<break>>
<</if>>
<</for>>
/* Remember a max of 10 high scores, but always remember the most recent one. */
<<if $PERM_hiscores.length > 9 & _saved == false>>
<<remember $PERM_hiscores = $PERM_hiscores.slice(0,9)>>
<<elseif $PERM_hiscores.length > 100>>
<<remember $PERM_hiscores = $PERM_hiscores.slice(0,10)>>
<</if>>
/* If we didn't add it already, add it to the end. */
<<if !_saved>>
<<remember $PERM_hiscores.push($hiscore)>>
<<remember $PERM_most_recent_score = $PERM_hiscores.length-1>>
<</if>>
Using <<remember>> rather than <<set>> means that the variable should persist across game loads. I give names of remembered variables the PERM_ prefix to remind me which ones they are.
Then you can display the hiscores by iterating over the array:
<<for _n = 0; _n < $PERM_hiscores.length; _n++>>
NAME: <<print $PERM_hiscores[_n].name>>
SCORE: <<print $PERM_hiscores[_n].final_score>>
<</for>>
(That's a minimal example to show the logic--you'll probably want to modify it in order to display the scores in a nice table.)
Because you've used <<remember>> rather than <<set>> for the high scores, there's nothing else you need to do in order to save the state of the game.
You can add a link to restart the game like this:
<<link "Restart">>
<<script>>
Engine.restart();
<</script>>
<</link>>
That restarts with no warning as soon as they click the link. If you want to make the player confirm, you can replace Engine.restart(); with UI.restart(); .