Discuss Scratch

Eld4n79
Scratcher
20 posts

How do I play random music after a sound effect?

Recently. I’ve been making a outro for my grounded projects, after the credits sound plays it switches to a random song, but sometimes it chooses that credits noise. How do I tell the code to choose the music only?


Here is my code:
whenIreceive end
playsound credits
foreverplaysound(pick random () to (10))

If you can, please attach a link to the project that can load music.
KralEjder65
Scratcher
48 posts

How do I play random music after a sound effect?

I think it works with this:

whenIreceiveEnd
playsoundcredits
foreverplaysound(pick random () to (10))untildone

Last edited by KralEjder65 (Sept. 14, 2023 16:47:10)

KralEjder65
Scratcher
48 posts

How do I play random music after a sound effect?

In your code its always playing a random music and it has no cooldown.So i fixed it
RecessFailsOffical
Scratcher
1000+ posts

How do I play random music after a sound effect?

THE EXPLANATION:

Say you have 15 songs (including credits) in your project. In the menu, place the credits as the last sound. Then, you can add a pick random 1 through 14 so it doesn't have a chance to play the credits song.


THE SOLUTION:

In your backdrop sprite, include this:

whenIreceiveEndplaysoundcreditsuntildoneforeverplaysound(pick random (1) to (14))untildone

I hope this helps!
MaxonStudios
Scratcher
1 post

How do I play random music after a sound effect?

whenIreceiveforeverplaysounduntildone

Powered by DjangoBB