Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » My variable won't change!
- Andyrew52
-
2 posts
My variable won't change!
No longer a problem. Thanks so much, deck26 
Please help, I am trying to change my variable but it always stays the same no matter what I try.
This is my project:
https://scratch.mit.edu/projects/226108039/ (currently working on it so it is not up yet)
This is what the code looks like:

Please help, I am trying to change my variable but it always stays the same no matter what I try.
This is my project:
https://scratch.mit.edu/projects/226108039/ (currently working on it so it is not up yet)
This is what the code looks like:
when I start as a clone
game stuff
if <touching color [#FFC7ED]> then
change (No. Left) by (1)
if <(No. Left) = [0]> then
change (Level) by (1)
end
delete this clone
Last edited by Andyrew52 (June 5, 2018 20:50:02)
- deck26
-
1000+ posts
My variable won't change!
Do yourself a big favour and look at the platformer tutorial by @griffpatch_tutor. that script with multiple if touching colour/change y by 1 blocks appears regularly here as a problem.
Don't switch backdrop in a forever loop - you're just giving Scratch extra work to do. Just use wait until not backdrop# = level.
Your main problem, I suspect, is that NoLeft is a local variable so each clone has its own copy. So if a clone changes the value the sprite won't see that change - it has to be a global (all sprites) variable for that to work.
Don't switch backdrop in a forever loop - you're just giving Scratch extra work to do. Just use wait until not backdrop# = level.
Your main problem, I suspect, is that NoLeft is a local variable so each clone has its own copy. So if a clone changes the value the sprite won't see that change - it has to be a global (all sprites) variable for that to work.
- Happysoul05
-
100+ posts
My variable won't change!
Check the variable you want to change (like levels) is for one sprite or all sprites.
- Andyrew52
-
2 posts
My variable won't change!
Do yourself a big favour and look at the platformer tutorial by @griffpatch_tutor. that script with multiple if touching colour/change y by 1 blocks appears regularly here as a problem.
Don't switch backdrop in a forever loop - you're just giving Scratch extra work to do. Just use wait until not backdrop# = level.
Your main problem, I suspect, is that NoLeft is a local variable so each clone has its own copy. So if a clone changes the value the sprite won't see that change - it has to be a global (all sprites) variable for that to work.
Thanks so much deck26 it works now!!
- deck26
-
1000+ posts
My variable won't change!
Please create your own new topic rather than necroposting. my varible y keeps on mis funtioning
- codingGP
-
7 posts
My variable won't change!
My variable is not changing to
.I stayed a hour to fix it and still not working…

- deck26
-
1000+ posts
My variable won't change!
Please create your own new topic. Share and identify the project and give a bit more infomation. My variable is not changing to.I stayed a hour to fix it and still not working…
- nwibo0
-
4 posts
My variable won't change!
hello my varible now will change
define ()
when green flag clicked
forever
end
- codingGP
-
7 posts
My variable won't change!
hers the project https://scratch.mit.edu/projects/400219449/
- deck26
-
1000+ posts
My variable won't change!
https://scratch.mit.edu/projects/400219449/Create a new topic please. hers the project
- deck26
-
1000+ posts
My variable won't change!
Go the top of the forum and click on New Topic. That is the best way to ask for help instead of posting on someone else's old topic as you've done. Give more details of the problem as well - which variable should be changing and isn't? What should make it change? Make it easier for those helping to directly look at the issue. what do you mean in topic?
- The_Imaginarium
-
1000+ posts
My variable won't change!
what do you mean in topic?
This Problem Is Resolved.
Go To Here: https://scratch.mit.edu/discuss/7/ And Click The Blue Button At The Top Right Of The Page.
Last edited by The_Imaginarium (Aug. 29, 2020 14:33:23)
- joshuaho
-
1000+ posts
My variable won't change!
Well stated. Yes - it's always better to create your own topic for your questions rather than posting on an old one. Go the top of the forum and click on New Topic. That is the best way to ask for help instead of posting on someone else's old topic as you've done. Give more details of the problem as well - which variable should be changing and isn't? What should make it change? Make it easier for those helping to directly look at the issue.

- Discussion Forums
- » Help with Scripts
-
» My variable won't change!