Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Forever Button Doesn't Work
- Horsy10
-
Scratcher
2 posts
Forever Button Doesn't Work
Hi. I was making a program and I needed a block to play a song forever until I pressed the stop button. I found “forever” in control blocks, but it does not work. HEEEEEELP!
- Dang259
-
Scratcher
3 posts
Forever Button Doesn't Work
The “forever” block (loop) does work. If it doesn't, you probably have a mistake in your code.
- footsocktoe
-
Scratcher
1000+ posts
Forever Button Doesn't Work
Try this…
forever
play sound [my song v] until done
end
- crisostimo
-
Scratcher
500+ posts
Forever Button Doesn't Work
He's asking about being able to stop it with a button click. In this case you don't want to use ‘forever’ you want to use ‘repeat until’. Then have your sprite click set a variable you can check in the condition on ‘repeat until’.
- footsocktoe
-
Scratcher
1000+ posts
Forever Button Doesn't Work
He's asking about being able to stop it with a button click. In this case you don't want to use ‘forever’ you want to use ‘repeat until’. Then have your sprite click set a variable you can check in the condition on ‘repeat until’.
set [stop song v] to [false ]
repeat until <(stop song) = [true ]>
play sound [ v] until done
end
when [ v] key pressed
set [stop song v] to [ true]
- asivi
-
Scratcher
1000+ posts
Forever Button Doesn't Work
That script works by pressing a key.He's asking about being able to stop it with a button click. In this case you don't want to use ‘forever’ you want to use ‘repeat until’. Then have your sprite click set a variable you can check in the condition on ‘repeat until’.set [stop song v] to [false ]
repeat until <(stop song) = [true ]>
play sound [ v] until done
endwhen [ v] key pressed
set [stop song v] to [ true]
For a sprite button you may do
when this sprite clicked // put this in the sprite button
set [stop song v] to [ true]
- Phosphor
-
Scratcher
71 posts
Forever Button Doesn't Work
Maybe the problem is the “play sound” type of block? There are two kinds.
When each is placed in a forever loop by itself, here's what happens:
play sound [ v]
play sound [ v] until done
When each is placed in a forever loop by itself, here's what happens:
forever
play sound [ v] //The sound stutters and restarts, or maybe you just hear silence. Boo!
end
forever
play sound [ v] until done //The sound correctly finishes before restarting. Hooray!
end
- powercon5
-
Scratcher
1000+ posts
Forever Button Doesn't Work
also if you want it to straight away you need to addThat script works by pressing a key.He's asking about being able to stop it with a button click. In this case you don't want to use ‘forever’ you want to use ‘repeat until’. Then have your sprite click set a variable you can check in the condition on ‘repeat until’.set [stop song v] to [false ]
repeat until <(stop song) = [true ]>
play sound [ v] until done
endwhen [ v] key pressed
set [stop song v] to [ true]
For a sprite button you may dowhen this sprite clicked // put this in the sprite button
set [stop song v] to [ true]
stop all soundsso something like this
when this sprite clicked // put this in the sprite button
set [stop song v] to [ true]
stop all sounds
- asivi
-
Scratcher
1000+ posts
Forever Button Doesn't Work
Let me show you an example with a button for play and stop (with fade out) https://scratch.mit.edu/projects/101142477
- Horsy10
-
Scratcher
2 posts
Forever Button Doesn't Work
Thanks for all your help. Maybe the problem is my browser and computer model.

- yellowbunny2021
-
Scratcher
1 post
Forever Button Doesn't Work
Problem fixed! thanks to Phosphor, you're amazing thank you!
- Discussion Forums
- » Help with Scripts
-
» Forever Button Doesn't Work







