Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Username blocks?
- pizza_king16
-
100+ posts
Username blocks?
Could some kind scratcher plz reveal to me how to use the username block? I’d be much obliged!
- ResExsention
-
1000+ posts
Username blocks?
Could some kind scratcher plz reveal to me how to use the username block? I’d be much obliged!
It basically stores the username of the person playing it. If you need to refer to the player you can use that.
For example, if I played your project, and you did this:
forever
if <(username) = [ResExsention]> then
say [Hi Res!]
else
say [Hi someone else!]
end
end
- FateSealer
-
100+ posts
Username blocks?
If you write a toy operating system in Scratch, you may want the user to sign in (login) by requesting their “Name” and “Password”. Of course, you can use the “username” block to fill the “Name” of the user, and request the password only.
- codeman1044
-
1000+ posts
Username blocks?
Block:
This block returns the username of a viewer. It returns the username along with an asterisk ( * ) if the viewer is a Scratch Team member. It returns empty if the viewer is not signed in. I believe it is case sensitive as well.
Usage:
Getting a username for an RPG
Cloud tracking*
Checking to see if the viewer is signed in (can be used to make sure that the game doesn't run into roadblocks if there isn't a username, and/or can be used to check if a user is an ST member)
Can be used for save files for games
Can be used for additions for if a friend is playing or something
Other things
Pros:
Tracks the username of a person
Cons:
None (unless you believe that the game is stalking you for your username)
*You're a new scratcher, so cloud variables won't work for you. They also won't work for people who aren't signed in. Also, cloud is hard to work with.
(Username)How it works:
This block returns the username of a viewer. It returns the username along with an asterisk ( * ) if the viewer is a Scratch Team member. It returns empty if the viewer is not signed in. I believe it is case sensitive as well.
Usage:
Getting a username for an RPG
Cloud tracking*
Checking to see if the viewer is signed in (can be used to make sure that the game doesn't run into roadblocks if there isn't a username, and/or can be used to check if a user is an ST member)
Can be used for save files for games
Can be used for additions for if a friend is playing or something
Other things
Pros:
Tracks the username of a person
Cons:
None (unless you believe that the game is stalking you for your username)
*You're a new scratcher, so cloud variables won't work for you. They also won't work for people who aren't signed in. Also, cloud is hard to work with.
- Rocket-Flier
-
100+ posts
Username blocks?
Here are a few uses of the username block:
Says hi to you:
Says hi to you:
say (join (join [Hello there, ] (username)) [!]) for (2) secsActivates a test mode:
if <[admins v] contains (username) ?> thenGives a surprise to a certain user.
set [test mode v] to [on]
else
set [test mode v] to [off]
end
if <(username) = [pizza_king16]> thenCounts the number of famous scratchers who view your project (Note: Wait until you are a scratcher to use cloud variables):
broadcast [suprise v]
end
if <[famous scratchers v] contains (username) ?> then
change [☁famous views v] by (1)
end
- pizza_king16
-
100+ posts
Username blocks?
How do you get it to save individual progress in a game?
- codeman1044
-
1000+ posts
Username blocks?
If you use a save code in a game just add the username to it (encrypt it if needed)
- Underseeker5
-
33 posts
Username blocks?
the username block checks the viewer's username so you can do stuff like this:
say (join [hello,] (username))
- --Explosion--
-
1000+ posts
Username blocks?
It is easy to make a famous scratcher counter or provide an extra feature only avalible to a friend, but if you just click see inside and change the code around you can getthe extra feature yourself
- --Explosion--
-
1000+ posts
Username blocks?
Thr username block reports the person using the project's username, for example if you played a game that reported your username, it would report pizza_king16 for you and staffordboys for me
- EIephant_Lover
-
500+ posts
Username blocks?
Instead of asking the same question as the original post, you can follow it to see what other people say by clicking “Follow Discussion,” the little blue box in the bottom right. can someone tell me how to use the username block
Also, please don't blockspam.say [PLease Help] for (0) secs
- Rkjartan
-
7 posts
Username blocks?

- Oumuamua
-
1000+ posts
Username blocks?
unfortunately this signature has been corrupted by an evil cat blockCAT BLOCKS WILL RULE
LOL!
Please do not spam!.
Thanks.
- FoofJr
-
100+ posts
Username blocks?
So how does it work? It is just a reporter block that returns the name of the person running the project.
So you could use
instead of
The latter means that people could put in inappropriate or offensive names. The former is constant at all times.
Probably a better feature for this is when you are debugging a project and don't want cheat codes.
Just make an if block checking if you are playing. I use this a lot because watching the same things play out is boring when you debug.
Hope this helps!
So you could use
say (join[hello ](username))
instead of
ask [what is your namer?] and wait
say (join[hello ](answer)
The latter means that people could put in inappropriate or offensive names. The former is constant at all times.
Probably a better feature for this is when you are debugging a project and don't want cheat codes.
Just make an if block checking if you are playing. I use this a lot because watching the same things play out is boring when you debug.
Hope this helps!
- NastyPigletz
-
9 posts
Username blocks?
<(username) = (username)>
This block detects if the user is connected to your project or not. If
<not<(username) = (username)>
then the user is disconnected. This helps you to do cloud mutiplayer projects
Last edited by NastyPigletz (April 15, 2020 17:57:20)
- deck26
-
1000+ posts
Username blocks?
Not like that it doesn't! username will always be equal to itself.<(username) = (username)>
This block detects if the user is connected to your project or not. If<not<(username) = (username)>
then the user is disconnected. This helps you to do cloud mutiplayer projects
Always happy to be proved wrong.
- Discussion Forums
- » Help with Scripts
-
» Username blocks?