Discuss Scratch

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

Hi i'm trying to know how to make music stop and play when I click a sprite? Can someone help? Thanks!

,———-BroOn4tn1t———-

xMystic416
Scratcher
100+ posts

how to make music play and stop when clicking a sprite

when this sprite clicked
broadcast [ music]
when I receive [  music]
if <[music] = [off]> then


set [ music] to [on]
play sound [ v] until done
else
set [ music] to [off]
stop all sounds
end
for the stop all sounds you can also switch it with the
set volume to (0) %
if it doesn't work

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

ok thanks ill try it

,———-BroOn4tn1t———-

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

wait I can't find the “set music to on” block

,———-BroOn4tn1t———-

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

it did not work

,———-BroOn4tn1t———-

mstone326
Scratcher
1000+ posts

how to make music play and stop when clicking a sprite

BroOn4tn1t wrote:

wait I can't find the “set music to on” block

The set music to block is a variable. You have to go to variables and then create a variable called music. A variable can be named anything, always best to name them something that is relevant as in this case.

Try again, the above script should work after you create the variable.

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

ok thanks mstone326

,———-BroOn4tn1t———-

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

when i click the sprite it just restarts the song

,———-BroOn4tn1t———-

xMystic416
Scratcher
100+ posts

how to make music play and stop when clicking a sprite

BroOn4tn1t wrote:

when i click the sprite it just restarts the song
Can you share it so I can see what is wrong with the script?

BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

yeet
the script is on the play/stop music here sprite

Last edited by BroOn4tn1t (Feb. 26, 2020 22:12:02)


,———-BroOn4tn1t———-

Fire-Scourge
New to Scratch
2 posts

how to make music play and stop when clicking a sprite

how do you pick the song?
Fire-Scourge
New to Scratch
2 posts

how to make music play and stop when clicking a sprite

nvm
whistle46
Scratcher
1 post

how to make music play and stop when clicking a sprite

when green flag clicked
play sound [ v] until done
pen up
AmazingKeller
Scratcher
63 posts

how to make music play and stop when clicking a sprite

hmm maybe
when green flag clicked
forever

end
play sound [ v]
when this sprite clicked
stop all sounds

Namibia the land of the brave!!
BroOn4tn1t
Scratcher
39 posts

how to make music play and stop when clicking a sprite

AmazingKeller wrote:

hmm maybe
when green flag clicked
forever

end
play sound [ v]
when this sprite clicked
stop all sounds
that wont work since its a forever loop it will play forever

,———-BroOn4tn1t———-

Aspirus
Scratcher
14 posts

how to make music play and stop when clicking a sprite

RebeccaKi
Scratcher
3 posts

how to make music play and stop when clicking a sprite

how do you do the thing where ok so it plays music and then when you click another sprite the music stops playing im trying to make a game
lion334
Scratcher
100+ posts

how to make music play and stop when clicking a sprite

Guys stop posting here I think it's already solved.
And this Post is 2 years old.

Hi, I'm Mirau or lion334

Made some cool game a while ago: You're not gonna click it though… right?


Conduit7
Scratcher
100+ posts

how to make music play and stop when clicking a sprite

BroOn4tn1t wrote:

Hi i'm trying to know how to make music stop and play when I click a sprite? Can someone help? Thanks!
okay so just use this code:
when green flag clicked
set [isMuted? v] to (0)
forever
play sound [music v] until done
end

when this sprite clicked
if <(isMuted?) = (0)> then
set [isMuted? v] to (1)
set volume to (0) %


else
set [isMuted? v] to (0)
set volume to (100) %
end


Hi, I'm Conduit.

I speedrun Massive Multiplayer Platformer (0'55.0 seconds), Appel (18.9 level 1, 15.0 level 3), and Getting Over It (1'38)

Conduit7
Scratcher
100+ posts

how to make music play and stop when clicking a sprite

RebeccaKi wrote:

how do you do the thing where ok so it plays music and then when you click another sprite the music stops playing im trying to make a game
just use the same code i already put up lol


Hi, I'm Conduit.

I speedrun Massive Multiplayer Platformer (0'55.0 seconds), Appel (18.9 level 1, 15.0 level 3), and Getting Over It (1'38)

Powered by DjangoBB