Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Changing background when pressing a button
- Cute-eyes
-
Scratcher
1 post
Changing background when pressing a button
When my projects runs I have “switch backdrop to backdrop 1”. Later in the code I have “if key down arrow pressed then - switch backdrop to backdrop2” followed with more code on a new line. But when I run the project nothing happens when I press down. The rest of the code runs as normal.
What I have tried:
changing the key pressed from space to down arrow - no change
moving the rest of the code into the “if key down arrow pressed” line - now everything in the “if…” is not working
Can anybody help me please?

What I have tried:
changing the key pressed from space to down arrow - no change
moving the rest of the code into the “if key down arrow pressed” line - now everything in the “if…” is not working
Can anybody help me please?

- DaEpikDude
-
Scratcher
1000+ posts
Changing background when pressing a button
Either your first script is in a forever loop when it shouldn't be or your second isn't when it should be. If it's not it just checks once, it won't check again.
If you only want it to run once you can use “wait until”.
If you only want it to run once you can use “wait until”.
- deck26
-
Scratcher
1000+ posts
Changing background when pressing a button
Sharing what you have saves us guessing.
- scratchtwins-691
-
Scratcher
100+ posts
Changing background when pressing a button
Hi! Here are some things you need to check:
Is a When Green Flag Clicked block before your codes?
Did you put the codes into the backgrounds and not the sprites?
Did you put the first code into a Forever block? If yes, then remove the Forever block.
I hope this helped!

Is a When Green Flag Clicked block before your codes?
Did you put the codes into the backgrounds and not the sprites?
Did you put the first code into a Forever block? If yes, then remove the Forever block.
I hope this helped!


Last edited by scratchtwins-691 (Oct. 13, 2017 12:49:37)
- HittmanAAlt
-
New Scratcher
2 posts
Changing background when pressing a button
Can you post the code for us to see, please?
- 26afitzpatrick
-
New Scratcher
1 post
Changing background when pressing a button
when green flag clicked
if <> then
<touching color [#50fb02] ?>
switch backdrop to [ v]
- YA1050G
-
Scratcher
1 post
Changing background when pressing a button
When key pressed to switch backdropm
When (dropdown) key pressed:
Change backdrop to (backdrop name)
But if its when a sprite touches a colour or if a variable says a certain thing, heres how to do it:
When flag clicked:
The part inside the is the if then.
Inside the if then, if it is a variable, use the (blank)
blank, usually says 50 when you place it but it can be edited)
Go to variables get a round block of the variable you want, place that in the first blank.
In the second blank, add what the variable should say to change the backdrop.
But if its a sprite touching a colour or anither sprite, add the touching (colour) block or the touching (sprite name) block
Hope this made sense.
When (dropdown) key pressed:
Change backdrop to (backdrop name)
But if its when a sprite touches a colour or if a variable says a certain thing, heres how to do it:
When flag clicked:
The part inside the is the if then.
Inside the if then, if it is a variable, use the (blank)
blank, usually says 50 when you place it but it can be edited)Go to variables get a round block of the variable you want, place that in the first blank.
In the second blank, add what the variable should say to change the backdrop.
But if its a sprite touching a colour or anither sprite, add the touching (colour) block or the touching (sprite name) block
Hope this made sense.
- NanoBug_
-
Scratcher
78 posts
Changing background when pressing a button
There is a solution!
repeat this code as many times you need to ask me if u need more details
repeat this code as many times you need to ask me if u need more details
when [KEY] key pressed
switch backdrop to [BACKDROP]
- Rexperseud
-
Scratcher
18 posts
Changing background when pressing a button
I don't need help making stuff but I DO need help with thinking of stuff to make
think [What should I make?]
- GreenPaintNew
-
Scratcher
4 posts
Changing background when pressing a button
when green flag clicked
switch backdrop to [ v]
or
when [ v] key pressed
switch backdrop to [ v]
Just like that!
Last edited by GreenPaintNew (Oct. 29, 2023 02:50:37)
- Asyadfghjkl
-
Scratcher
100+ posts
Changing background when pressing a button
YOU MUT BE PRESSING THE BUTTON WHEN THE IF RUNS
ELSE BACKDROP WILL NOT CHANGE
ELSE BACKDROP WILL NOT CHANGE
Last edited by Asyadfghjkl (Oct. 29, 2023 04:03:40)
- TheGoldrex
-
Scratcher
1 post
Changing background when pressing a button
e
when green flag clicked
say [Follow Me and give me ideas for scratch projects]
define
say [why cant i make my project change to my main menu when the red octagon is clicked?]
- Discussion Forums
- » Help with Scripts
-
» Changing background when pressing a button
