Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to make highscore
- ChewIsNotTaken
-
Scratcher
12 posts
how to make highscore
Guys how to make a current player highscore , like u set high score variable to 0 when hes new but if hes not new the high score doesnt resets
- deck26
-
Scratcher
1000+ posts
how to make highscore
For personal high scores you need to encode the username and store the value. See the wiki page on Encoding & Decoding. So you can extract the data from the cloud and see whether the user is there or not when deciding whether you need to add them as a new user or only update their score as necessary.
Cloud variables are the same for all users which is why you need to do it this way.
Cloud variables are the same for all users which is why you need to do it this way.
- ChewIsNotTaken
-
Scratcher
12 posts
how to make highscore
For personal high scores you need to encode the username and store the value. See the wiki page on Encoding & Decoding. So you can extract the data from the cloud and see whether the user is there or not when deciding whether you need to add them as a new user or only update their score as necessary.im srry but im kinda new to this highscore thing can u demonsrate it in blocks here
Cloud variables are the same for all users which is why you need to do it this way.
- deck26
-
Scratcher
1000+ posts
how to make highscore
https://en.scratch-wiki.info/wiki/Encoding_and_Decoding_Cloud_Data - I'm not going to create scripts here when there is a tutorial page already available.For personal high scores you need to encode the username and store the value. See the wiki page on Encoding & Decoding. So you can extract the data from the cloud and see whether the user is there or not when deciding whether you need to add them as a new user or only update their score as necessary.im srry but im kinda new to this highscore thing can u demonsrate it in blocks here
Cloud variables are the same for all users which is why you need to do it this way.
The point is that if you just use a cloud variable and set it to your high score there's no point me resetting that to my high score or not being able to beat it to record my own best score. So what you need to do is store both the user and the score for that user.
So for example, if our usernames were abc and def you might be the first users and store abc12 to the cloud. I then play the game and add my own data to the end so the cloud variable now reads abc12def8. Another user plays and gets added to the end.
So when you get a high score you need to extract the data from the cloud (to make sure it is up to date within your instance of the project), recreate the variable, including the data for other users, and save it.
This is complicated by the fact that you only have 10 cloud variables to play with and each only holds a max of 256 digits so usernames need encoding. So now we might have 01020300012 instead of abc12 - 01 for A, 02 for B etc, 00 as a separator (else how do you know where the username ends) and the score expanded to 3 digits. By keeping the score to a fixed number of digits we know where the next username starts
There are no doubt projects that give an engine to do all this for you. It is a good programming exercise but is not a trivial thing to do.
Last edited by deck26 (March 2, 2023 09:15:27)
- UnscrambledEgg
-
Scratcher
100+ posts
how to make highscore
A highscore variable could be achieved through cloud variables (If you are a new Scratcher then you can't make those variables). You should also create a seperate non-cloud variable for the user's points and when a round of the game ends, check if the points are greater than the highscore, if so, set the highscore to that value.
If you don't wish for the highscore to be throughout all users, you can use a list for history.
If you don't wish for the highscore to be throughout all users, you can use a list for history.
- deck26
-
Scratcher
1000+ posts
how to make highscore
A highscore variable could be achieved through cloud variables (If you are a new Scratcher then you can't make those variables). You should also create a seperate non-cloud variable for the user's points and when a round of the game ends, check if the points are greater than the highscore, if so, set the highscore to that value.What do you mean use a list for history? Lists aren't saved in the way cloud variables are.
If you don't wish for the highscore to be throughout all users, you can use a list for history.
- 67broski
-
Scratcher
3 posts
how to make highscore
To make highscore you need to first make score then do this:
(Ik this forum was made 2 years ago)
when green flag clickedThis will make it so that if the score is higher than the high score than it will make a new highscore.
set [(score)] to [0]
forever
if <(score) > (☁ highscore)> then
set [(☁ highscore)] to (score)
end
end
(Ik this forum was made 2 years ago)
Last edited by 67broski (Oct. 6, 2025 03:00:55)
- Discussion Forums
- » Help with Scripts
-
» how to make highscore



