Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a 'Next song' button?
- Bellamcintire
-
Scratcher
71 posts
How do I make a 'Next song' button?
I am trying to make a clicker and want there to be a next song button and I have a total of 11 songs but how do I play the next song?
- Lirey
-
Scratcher
100+ posts
How do I make a 'Next song' button?
this plays the next song in order of the songs in the sound tab
when green flag clickedor would you want the user to be able to pick their next song?
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
- Spentinium
-
Scratcher
100+ posts
How do I make a 'Next song' button?
when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
set [songs v] to (amount of songs :: grey)
...
broadcast (next song v)
when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (amount of songs)) + (1))
create clone of (myself v)
when I start as a clone
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
This code is untested so use it at your own risk.
Last edited by Spentinium (July 17, 2023 18:03:41)
- bRuHbRuHmEmEmAn
-
Scratcher
500+ posts
How do I make a 'Next song' button?
They were asking how they could change the song upon a click of a button aswell.when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
delete all of [song list v] :: list
add [song 1 name] to [song list v]
add [song 2 name] to [song list v]
...
broadcast (next song v)
when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (length of [song list v])) + (1))
create clone of (myself v)
when I start as a clone
start sound (item (current song) of [song list v]) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
This code is untested so use it at your own risk.
- Spentinium
-
Scratcher
100+ posts
How do I make a 'Next song' button?
They were asking how they could change the song upon a click of a button aswell.when gf clicked
set [is a clone? v] to (0) // for this sprite only
set [current song v] to (0)
delete all of [song list v] :: list
add [song 1 name] to [song list v]
add [song 2 name] to [song list v]
...
broadcast (next song v)
when I receive [next song v]
if <(is a clone?) = (1)> then
delete this clone
end
set [current song v] to (((current song) mod (length of [song list v])) + (1))
create clone of (myself v)
when I start as a clone
start sound (item (current song) of [song list v]) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
This code is untested so use it at your own risk.
when this sprite clicked
broadcast (next song v)
- medians
-
Scratcher
1000+ posts
How do I make a 'Next song' button?
when I start as a cloneIsn’t it play sound lol even in 3.0 you colored it for nothing
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
Last edited by medians (July 17, 2023 18:31:22)
- Bellamcintire
-
Scratcher
71 posts
How do I make a 'Next song' button?
this plays the next song in order of the songs in the sound tabOkay!when green flag clickedor would you want the user to be able to pick their next song?
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
- Bellamcintire
-
Scratcher
71 posts
How do I make a 'Next song' button?
this plays the next song in order of the songs in the sound tabI just tried it and it works! Tysm!!!when green flag clickedor would you want the user to be able to pick their next song?
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)
- Lirey
-
Scratcher
100+ posts
How do I make a 'Next song' button?
Great to hear! I'm glad it worked out for youthis plays the next song in order of the songs in the sound tabI just tried it and it works! Tysm!!!when green flag clickedor would you want the user to be able to pick their next song?
set [ variable v] to [1]
when this sprite clicked
change [ variable v] by (1)
stop all sounds
play sound (variable)

- Spentinium
-
Scratcher
100+ posts
How do I make a 'Next song' button?
Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.when I start as a cloneIsn’t it play sound lol even in 3.0 you colored it for nothing
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
- medians
-
Scratcher
1000+ posts
How do I make a 'Next song' button?
medians!!!Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.when I start as a cloneIsn’t it play sound lol even in 3.0 you colored it for nothing
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done

- ACriticIGuess
-
Scratcher
16 posts
How do I make a 'Next song' button?
simple.
play sound [song1 v] until done
play sound [song2 v] until done
- Spentinium
-
Scratcher
100+ posts
How do I make a 'Next song' button?
medians mix-up momentmedians!!!Scratch is the world’s largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization. Scratch promotes computational thinking and problem solving skills; creative teaching and learning; self-expression and collaboration; and equity in computing. Scratch is always free and is available in more than 70 languages.when I start as a cloneIsn’t it play sound lol even in 3.0 you colored it for nothing
start sound (current song) until done :: sound
broadcast (next song v) :: grey // will play the next song if the current one is done
- ducky3624
-
Scratcher
22 posts
How do I make a 'Next song' button?
This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!
This is the sound code that this strategy only works for
now the next sound code!
pls tell me if it works and if it does then tell me if its fine or not! please quote!
This is the sound code that this strategy only works for
when green flag clicked
broadcast [music]
when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]
now the next sound code!
when I receive [i want next aka another random song]
stop all sounds
pls tell me if it works and if it does then tell me if its fine or not! please quote!
- Bellamcintire
-
Scratcher
71 posts
How do I make a 'Next song' button?
This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!Okey! Ty
This is the sound code that this strategy only works forwhen green flag clicked
broadcast [music]when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]
now the next sound code!when I receive [i want next aka another random song]
stop all sounds
pls tell me if it works and if it does then tell me if its fine or not! please quote!
- SpyCoderX
-
Scratcher
1000+ posts
How do I make a 'Next song' button?
This is unbelivible but I tried this and it actually works! but.. it worrks for another random sound sooo this isnt the excact answer but it is very close!Welcome to the Scratch Forums!
This is the sound code that this strategy only works forwhen green flag clicked
broadcast [music]when I receive [music]
play sound (pick random (1) to (11)) until done
broadcast [music]
now the next sound code!when I receive [i want next aka another random song]
stop all sounds
pls tell me if it works and if it does then tell me if its fine or not! please quote!
You can actually simplify your code to this:
when green flag clicked
forever
play sound (pick random (1) to (10)) until done
end
when I receive [next v]
stop all sounds
Anyway, please don’t reply to old or abandoned posts.
This is known as Necroposting and is considered spam.
Thanks, and have a good day!
Last edited by SpyCoderX (April 21, 2024 23:32:10)
- Discussion Forums
- » Help with Scripts
-
» How do I make a 'Next song' button?








