— there are some issues in the code.
You are not using the webstorage correctly. You also placed a Set Highscore to Highscore, therefore, and you defined highscore=0 ... so you will always have highscore as 0.
Another thing is that the order of execution does matter. When you die, you reset the global immediately... instead, you should have the webstorage (as step 3 below) and then reset the variables and layout. If not, you are just resetting and saving the highscore as 0.
1. Try this, use " " for all highscore value
2. On the start layout -> Webstorage -> Local key "highscore" exists | System -> Set highscore to WebStoreage.localValue("highscore")
3. On comparing the distance, webstorage-> set local key "highscore" to totaldistance
That worked on the mini test I did.