Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a sound play 1 time anytime i want?
- Partizajchik
-
Scratcher
4 posts
How to make a sound play 1 time anytime i want?
if i use for example this code:
when flag clicked
forever
if variable = number then
start sound
then it makes that sound forever and i want 1 time. How to fix that?
when flag clicked
forever
if variable = number then
start sound
then it makes that sound forever and i want 1 time. How to fix that?
- ChompyChompee
-
Scratcher
14 posts
How to make a sound play 1 time anytime i want?
Here's how you fix that:
Hope that helped, have a nice day
!
when green flag clickedYou need it it wait into your variable isn't 1 so it doesn't loop, and when it zero it will reset and wait for it to be one agin to play the sound.
forever
if <(my variable) = [1]> then
play sound [meow] until done
wait until <not <(my variable) = [1]>>
end
wait until <not <[variable] = [1]>>is a helpful peace of code I use a lot
Hope that helped, have a nice day
!Last edited by ChompyChompee (May 5, 2024 15:49:04)
- BigNate469
-
Scratcher
1000+ posts
How to make a sound play 1 time anytime i want?
Or, if you want the rest of the code in the forever loop to run without waiting on the sound:
forevernote: the grey blocks represent any other code in your loop, I put them there as placeholders for whatever you put there.
...
if <(my variable) = [1]> then
play sound [ v]
set [my variable v] to [some value that isn't 1]
end
...
end
- Partizajchik
-
Scratcher
4 posts
How to make a sound play 1 time anytime i want?
thanks everyone! now i understand @ChompyChompee @BigNate469
- Discussion Forums
- » Help with Scripts
-
» How to make a sound play 1 time anytime i want?



