Discuss Scratch

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?
ChompyChompee
Scratcher
14 posts

How to make a sound play 1 time anytime i want?

Here's how you fix that:
when green flag clicked
forever
if <(my variable) = [1]> then
play sound [meow] until done
wait until <not <(my variable) = [1]>>
end
You 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.
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:
forever
...
if <(my variable) = [1]> then
play sound [ v]
set [my variable v] to [some value that isn't 1]
end
...
end
note: the grey blocks represent any other code in your loop, I put them there as placeholders for whatever you put there.
Partizajchik
Scratcher
4 posts

How to make a sound play 1 time anytime i want?

thanks everyone! now i understand @ChompyChompee @BigNate469
C7student4
New Scratcher
1 post

How to make a sound play 1 time anytime i want?

hi

Powered by DjangoBB