Discuss Scratch
- Discussion Forums
 - » Help with Scripts
 - » How Do I Make an RNG (Random Number Generator)?
        
         
- ThatDevXD
 - 
                            
						
						
                            Scratcher
                        
						
						 
3 posts
How Do I Make an RNG (Random Number Generator)?
For my game, I want to make a RNG and a sprite for each number, for example: I pick the 
Thanks, XD.
                        
                        
                    (pick random (1) to (10))and for each number there is a sprite. Which ever number it chooses, for example: 7. How can I make it to where sprite 7 to appear after the generator chose 7?
Thanks, XD.
- awesome-llama
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
How Do I Make an RNG (Random Number Generator)?
You could store the result in a variable and get the other sprites to check if that variable matches them.
                        
                        
                    set [result v] to (pick random (1) to (10))
broadcast [chosen number v]
// in other sprites:
when I receive [chosen number v]
if <(result) = [1]> then // put the sprite's number here
show
end
- musicROCKS013
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
How Do I Make an RNG (Random Number Generator)?
You could also do this:
                        
                        
                    broadcast (join [Random message] (pick random (1) to (10)))
- WillGaming123
 - 
                            
						
						
                            Scratcher
                        
						
						 
16 posts
How Do I Make an RNG (Random Number Generator)?
Try 
                        
                            set [value] to (pick random (1) to (10))Next you can have a sprite with the costumes from 1 to 9 being named the didget and use
switch costume to (value)That will use the costume! hope this helped
Last edited by WillGaming123 (June 28, 2022 08:08:36)
- park_tr
 - 
                            
						
						
                            Scratcher
                        
						
						 
36 posts
How Do I Make an RNG (Random Number Generator)?
I decided to do this for a burping:
                        
                            when I receive [ burp chance]
if <(pick random (1) to (10)) = [1]> then
switch costume to [burp v]
wait (0.5) secs
switch costume to [cat v]
end
Last edited by park_tr (June 29, 2022 13:15:01)
- feet_lol_pete
 - 
                            
						
						
                            Scratcher
                        
						
						 
5 posts
How Do I Make an RNG (Random Number Generator)?
how do I make a high scorrrrrrrrrr
                        
                        
                    - BigNate469
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
How Do I Make an RNG (Random Number Generator)?
how do I make a high scorrrrrrrrrr1. Please don't necropost
2. Create your own topic. There's a button at the top right of the main Help with Scripts page.
- Discussion Forums
 - » Help with Scripts
 - 
            » How Do I Make an RNG (Random Number Generator)? 
         






