Discuss Scratch
- Discussion Forums
 - » Help with Scripts
 - » How to make a shop
        
         
- Firerie
 - 
                            
						
						
                            Scratcher
                        
						
						 
16 posts
How to make a shop
Can anyone teach me how to make a shop? I see a lot of games with them and really want to know how to create one. here is my project: https://scratch.mit.edu/projects/401474815/editor/ If anyone has any idea on how to make one please let me know
                        
                        
                    - WildTraces
 - 
                            
						
						
                            Scratcher
                        
						
						 
100+ posts
How to make a shop
You need a currency system, after that make a shop button that sets the ‘shopOpen?’ variable to 1 and a close button that sets it to 0 and maybe a box behind the icons so you can see them better and it looks more professional. Use this script in each skin sprite:
Then use this in the player sprite:
                        
                        
                    when green flag clicked
go to x: (where ever) y: (where ever)
forever
if <(shopOpen?) = [1]> then
show
if <touching [mouse pointer v] ?> then
set [ghost v] effect to (20)
if <mouse down?> then
if <[skins v] contains [skin name] ?> then
set [current skin v] to [skin name]
else
if <not <(money) < [cost of skin]>> then
change [money v] by ((0) - (cost of skin))
add [skin name] to [skins v]
set [current skin v] to [skin name]
end
end
wait until <not <mouse down?>>
end
else
set [ghost v] effect to (0)
end
else
hide
end
end
Then use this in the player sprite:
when green flag clicked
set [current skin v] to [default]
forever
switch costume to [(current skin) v]
end
- Firerie
 - 
                            
						
						
                            Scratcher
                        
						
						 
16 posts
How to make a shop
wait where is the add skin name to skins and the skins contains skin name block?
                        
                        
                    - RainbowsToybox
 - 
                            
						
						
                            Scratcher
                        
						
						 
100+ posts
How to make a shop
So first make a variable for money, make a place to earn money. Make separate sprites that will be what you are buying (only make them visible when in the shop)
Here's the code for buying something:
Put this on the sprite of the item the player buys.
I hope this helped you, I'm not very good at coding. I used this store system for one of my games, so I thought I'd help.
                        
                            Here's the code for buying something:
when this sprite clickedThe money you change by depends on the price. If the item is 40 money things, put -40. (This removes 40 from the player's balance)
change [ Money] by ()
Put this on the sprite of the item the player buys.
I hope this helped you, I'm not very good at coding. I used this store system for one of my games, so I thought I'd help.
Last edited by RainbowsToybox (June 4, 2020 11:30:13)
- WildTraces
 - 
                            
						
						
                            Scratcher
                        
						
						 
100+ posts
How to make a shop
wait where is the add skin name to skins and the skins contains skin name block?
You need to press ‘make a list’ and call it skins
- RobotFishy
 - 
                            
						
						
                            Scratcher
                        
						
						 
1 post
How to make a shop
Um hi can anyone show me how to make a shop for guns?
                        
                        
                    - Lasting_Fall
 - 
                            
						
						
                            Scratcher
                        
						
						 
6 posts
How to make a shop
I need help making it so where you can  buy something but you cant have under 30 bits (Cash) can anyone help?
                        
                            Last edited by Lasting_Fall (Sept. 30, 2022 15:29:31)
- Discussion Forums
 - » Help with Scripts
 - 
            » How to make a shop 
         




