Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Score Leaderboard
- xyros90
-
Scratcher
25 posts
Score Leaderboard
Anyone know how I can make a leaderboard that shows the highest score for my game? I think it has something to do with cloud variables, I just don't know how to code it.
- DragonBeast829
-
Scratcher
100+ posts
Score Leaderboard
Cloud variables can't store lists natively, they can only store numbers which makes storing usernames and lists difficult (but not impossible! Just difficult). If you just want it to show the highest achieved score, then try something like
I haven't used cloud variables in a while, though. I think Griffpatch has a tutorial series on using them to make a game, so if you follow that I'm sure you'll be familiar enough with them to make what you want.
when I receive [update cloud high score v]
if <(score) > (☁ cloud high score)> then
set [☁ cloud high score v] to (score)
end
I haven't used cloud variables in a while, though. I think Griffpatch has a tutorial series on using them to make a game, so if you follow that I'm sure you'll be familiar enough with them to make what you want.
Last edited by DragonBeast829 (Oct. 12, 2026 19:24:15)
- CrazyRainbow35
-
Scratcher
54 posts
Score Leaderboard
So if you want a highest score you should use the script above by @DragonBeast829
If you want a leader board for highest 1st, 2nd, and 3rd then do this. (Note, this does not store exact usernames or anything like that)
If you want a leader board for highest 1st, 2nd, and 3rd then do this. (Note, this does not store exact usernames or anything like that)
when green flag clicked
forever
if <(Score) > (☁ 1st place)> then
set [☁️ 1st place v] to (score)
else
if <(score) > (☁ 2nd place)> then
set [☁️ 2nd place v] to (score)
else
if <(score) > (☁ 3rd place)> then
set [☁️ 3rd place v] to (score)
end
end
end
end
Last edited by CrazyRainbow35 (Oct. 12, 2026 16:25:21)
- EpicBrave
-
Scratcher
21 posts
Score Leaderboard
Cloud variables can't store lists…
Technically, they can. I've wrote a script that turns a variable into a list before. It's not difficult if you're familiar with parsing sets of data but I'd assume not everyone's done that. If I recall correctly, the code that parses could go like this:
set (i) to 0
set (parse) to blank
repeat until (i) > (length of (data))
if (join(letter (i) of (data))(letter ((i)+1) of (data)) = 00
add (parse) to (list)
set (parse) to blank
change (i) by 2
end
set (parse) to (join(parse)(letter (i) of (data)))
change (i) by 1
end
And you'd put that in a custom block with (data) as an argument. Tweak to your needs. This alone isn't going to work perfectly, if you're working with just number strings, making a cloud list is more difficult since the end marker I'm using is 00, which in the event a score contains 00, it misreads that as EOF. Instead of using raw numbers, I would assign numbers that turns one digit into two digits, such that 512 would become 050102. It makes the variable much larger, but a lot easier to work with.
Last edited by EpicBrave (Oct. 12, 2026 19:06:06)
- DragonBeast829
-
Scratcher
100+ posts
Score Leaderboard
Technically, they can.I know. I did say it was possible, but difficult. I wouldn't recommend trying to do it to someone who isn't familiar with cloud variables like OP.
edit: Thinking about it, I've actually had to make a few binary formats for other projects off of Scratch, so it wouldn't be too difficult for me to do as it seems like it would be similar to that. I'll probably end up using one in my next project here.
Last edited by DragonBeast829 (Oct. 12, 2026 19:19:16)
- EpicBrave
-
Scratcher
21 posts
Score Leaderboard
If you did say it was possible, then, your wording might have been a bit weird.
- UncappedCyanMarker
-
Scratcher
26 posts
Score Leaderboard
Cloud variables can't store lists…
Technically, they can. I've wrote a script that turns a variable into a list before. It's not difficult if you're familiar with parsing sets of data but I'd assume not everyone's done that. If I recall correctly, the code that parses could go like this:
set (i) to 0
set (parse) to blank
repeat until (i) > (length of (data))
if (join(letter (i) of (data))(letter ((i)+1) of (data)) = 00
add (parse) to (list)
set (parse) to blank
change (i) by 2
end
set (parse) to (join(parse)(letter (i) of (data)))
change (i) by 1
end
And you'd put that in a custom block with (data) as an argument. Tweak to your needs. This alone isn't going to work perfectly, if you're working with just number strings, making a cloud list is more difficult since the end marker I'm using is 00, which in the event a score contains 00, it misreads that as EOF. Instead of using raw numbers, I would assign numbers that turns one digit into two digits, such that 512 would become 050102. It makes the variable much larger, but a lot easier to work with.
pretty sure what he meant is scratch dosent have a built-in cloud list, you need to find a work-around with cloud variables
- ITS_DINO_XD
-
Scratcher
100+ posts
Score Leaderboard
keep in mind though that cloud variables have a character cap (i wanna say 236 but i cant be certain) that makes it way harder to make lists efficiently AND you the verity of characters you can use are very limited (if not only 1 or 2 actual letters allowed then none which again makes lists way harder to make)
- xyros90
-
Scratcher
25 posts
Score Leaderboard
So if you want a highest score you should use the script above by @DragonBeast829
If you want a leader board for highest 1st, 2nd, and 3rd then do this. (Note, this does not store exact usernames or anything like that)when green flag clicked
forever
if <(Score) > (☁ 1st place)> then
set [☁️ 1st place v] to (score)
else
if <(score) > (☁ 2nd place)> then
set [☁️ 2nd place v] to (score)
else
if <(score) > (☁ 3rd place)> then
set [☁️ 3rd place v] to (score)
end
end
end
end
Might use this one, though one question, is it possible to store usernames or nah?
- DragonBeast829
-
Scratcher
100+ posts
Score Leaderboard
Is it possible to store usernamesIt is, but it's a bit difficult. Usernames can have a-z, A-Z, 0-9, hyphens, and underscores, but only numbers can be stored in cloud variables and you can only have ten of them.
- Discussion Forums
- » Help with Scripts
-
» Score Leaderboard