Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can I make one time codes
- StarGjikolli
-
Scratcher
55 posts
How can I make one time codes
I’m trying to make a code works once and never again. Can someone help me?
when green flag clicked
say [exactly help me]
- deck26
-
Scratcher
1000+ posts
How can I make one time codes
You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
- StarGjikolli
-
Scratcher
55 posts
How can I make one time codes
You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
It’s for this: https://scratch.mit.edu/projects/1095167775
- deck26
-
Scratcher
1000+ posts
How can I make one time codes
Doesn't tell me anything!You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
It’s for this: https://scratch.mit.edu/projects/1095167775
- StarGjikolli
-
Scratcher
55 posts
How can I make one time codes
click add points and type 1234 over and overDoesn't tell me anything!You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
It’s for this: https://scratch.mit.edu/projects/1095167775
- StarGjikolli
-
Scratcher
55 posts
How can I make one time codes
You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
You know what? Once for one user.
- jmb1293634
-
Scratcher
1000+ posts
How can I make one time codes
this might work depending on exactly what you want:
when green flag clicked
wait until <whatever your condition is>
do whatever you want it to
- deck26
-
Scratcher
1000+ posts
How can I make one time codes
You asked me via my profile to help here but as far as I can see I've already answered the question. You need to store the encoded usernames of those who have used the code and, if necessary, a reference to the codes they've used. There's info in the Wiki about encoding usernames but cloud variables are generally a bit unreliable in my opinion - I believe they're down at the moment.You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
You know what? Once for one user.
Cloud variables are the same for all users so you can't just store the information that a code has been used - you need to store the information that it has been used by that user. Cloud variables only hold numerical digits so you have to encode the username.
- RicDiamond1477
-
Scratcher
100+ posts
How can I make one time codes
You can do this:You mean only once for one user or only once across all users? Why do you want to do this? What are you actually trying to achieve?
The only way I can see of doing this is to use cloud variables. If the use of a code is once per users you've have to encode the usernames and somehow record the codes they's used - you could use a shorter reference rather than the actual code(s) to save space. If a code is only once for all users you could just record which codes have been used without worrying about usernames.
You know what? Once for one user.
when green flag clicked
forever
if <[Whatever you are doing] = [1234]> then
Do what you want
stop [This Script v]
end
end
Last edited by RicDiamond1477 (Jan. 23, 2025 13:33:32)
- deck26
-
Scratcher
1000+ posts
How can I make one time codes
You can do this:when green flag clicked
forever
if <[Whatever you are doing] = [1234]> then
Do what you want
stop [This Script v]
end
end
I don't think you understand the question. If you don't use the cloud to save something the user can reload the project and there is nothing to prevent them using the code again.
- KamiraDuck
-
Scratcher
13 posts
How can I make one time codes
when green flag clicked
forever
if <[variable] = [0]> then
say [Not seen yet] for (2) secs
set [variable] to [1]
else
say [Already seen] for (2) secs
end
end
When somebody exits the game, the variables are saved.
- abrakaidabra
-
Scratcher
500+ posts
How can I make one time codes
Regular variables are reset when someone exits the gamewhen green flag clicked
forever
if <[variable] = [0]> then
say [Not seen yet] for (2) secs
set [variable] to [1]
else
say [Already seen] for (2) secs
end
end
When somebody exits the game, the variables are saved.
- abrakaidabra
-
Scratcher
500+ posts
How can I make one time codes
You would have to use cloud variables to save a user’s username using a cloud list. However, cloud variables are currently broken in scratch and do not save values after a player leaves the game. The other option would be to use python to connect to a different server used something like scratchclient or scratchattach, as used here.
- KamiraDuck
-
Scratcher
13 posts
How can I make one time codes
oh my bad, I tried making one on one of my games and it worked so bit confusing lol.
- abrakaidabra
-
Scratcher
500+ posts
How can I make one time codes
oh my bad, I tried making one on one of my games and it worked so bit confusing lol.If you are the creator and you’re running the game in the editor, then the variable would save.
- Kpate123
-
Scratcher
100+ posts
How can I make one time codes
Set a variable to 0 then do this
. . .
if <(foo) = [0]> then
set [foo v] to [1]
. . .
end
- abrakaidabra
-
Scratcher
500+ posts
How can I make one time codes
Set a variable to 0 then do thisBut then when you reload the project you could use the code again. . .
if <(foo) = [0]> then
set [foo v] to [1]
. . .
end
- Discussion Forums
- » Help with Scripts
-
» How can I make one time codes






