Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Pick random block keeps picking the same number.
- NightSplat_School
-
3 posts
Pick random block keeps picking the same number.
I'm trying to make a script that randomly picks between 3 sprites, but the “Pick random from _ to _” block keeps choosing the same number every time.
It picks one of the numbers and continues to choose that number whenever I restart the project.
Last edited by NightSplat_School (Oct. 1, 2022 03:36:40)
- legendary34678
-
1000+ posts
Pick random block keeps picking the same number.
Could you please post your project link here? Your code should work fine as it is.
- scratchgod2334
-
13 posts
Pick random block keeps picking the same number.
(comment helpful things here)
- PutneyCat
-
500+ posts
Pick random block keeps picking the same number.
The problem is unlikely to be the “pick random” block itself. You can be pretty sure it is picking a random number 1-3 every time it is run.
The problem will be some other aspect.
It's hard to say what without seeing the actual code. But e.g.:
(1) What is resetting the Sprite1, Sprite2, Sprite3, variables? If they are all already set to 1 the code above doesn't really do anything.
(2) Do you have another green flag script? Bear in mind that you can't really control the order in which green flag scripts are run.
Incidentally, depending on what else is in your code, the forever loop may be unnecessary (and inefficient).
The problem will be some other aspect.
It's hard to say what without seeing the actual code. But e.g.:
(1) What is resetting the Sprite1, Sprite2, Sprite3, variables? If they are all already set to 1 the code above doesn't really do anything.
(2) Do you have another green flag script? Bear in mind that you can't really control the order in which green flag scripts are run.
Incidentally, depending on what else is in your code, the forever loop may be unnecessary (and inefficient).
- sCrAtCh_139508
-
100+ posts
Pick random block keeps picking the same number.
this code makes it so it never pickes the same sprite 2 times in a row
- Oumuamua
-
1000+ posts
Pick random block keeps picking the same number.
Hi, please, explain clearly that whst you want to achieve…
Greets
Greets
Last edited by Oumuamua (Oct. 1, 2022 18:19:42)
- tank401
-
100+ posts
Pick random block keeps picking the same number.
have the set hing to random thing inside the forever thing
- KRAZYKING1010
-
92 posts
Pick random block keeps picking the same number.
Put the set sprite picker inside the forever loop
- cookieclickerer33
-
1000+ posts
Pick random block keeps picking the same number.
It’s not the random block, could you post the project ill be happy to help I'm trying to make a script that randomly picks between 3 sprites, but the “Pick random from _ to _” block keeps choosing the same number every time.It picks one of the numbers and continues to choose that number whenever I restart the project.
- NightSplat_School
-
3 posts
Pick random block keeps picking the same number.
Thank you! I will post the project link for those who wish to know more information. this code makes it so it never pickes the same sprite 2 times in a row
I won't change any scripts until I've gotten a for sure answer.
- NightSplat_School
-
3 posts
Pick random block keeps picking the same number.
Could you please post your project link here? Your code should work fine as it is.https://scratch.mit.edu/projects/737255611
The people picker sprite has all the script I included in this post as well as the Abby, Dani, and Dee sprites.
I may have already found a solution but I haven't changed any scripts just to be sure.
Last edited by NightSplat_School (Oct. 3, 2022 15:23:31)
- NightSplat
-
9 posts
Pick random block keeps picking the same number.
I have found a solution! I got rid of useless variables, and the “pick random” block works as intended now!
Here I have gotten rid of the forever script and put the individual sprite scripts below into each sprite based on their number.
Thank you all so much for your help!
Here I have gotten rid of the forever script and put the individual sprite scripts below into each sprite based on their number.
Thank you all so much for your help!

Last edited by NightSplat (Oct. 3, 2022 17:43:45)
- NightSplat
-
9 posts
Pick random block keeps picking the same number.
This message and the one above were made using my main account. NightSplat_School is my school acount.
- Discussion Forums
- » Help with Scripts
-
» Pick random block keeps picking the same number.