Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with music!!!
- RUBIXS
-
60 posts
Help with music!!!
Hey Scratchers!!!
I'm working on a game that has a soundtrack too it and i wanted to add a mute feature by pressing “m”
But its not working.
Hope you guys can help
I'm working on a game that has a soundtrack too it and i wanted to add a mute feature by pressing “m”
But its not working.
Hope you guys can help

- Dundil
-
11 posts
Help with music!!!
Just add a command set volume to 0% when “m” key is pressed.
- dracae
-
1000+ posts
Help with music!!!
Try this:
When GreenFlag clicked
Set volume to 100%
When m key is pressed
Set volume to ((abs of ((volume / 100) - 1)) * 100) %
Abs means absolute value.
Plug in 100% and 0% to see how it works.
Hope I helped!
(EDIT: This switches the volume back and forth from 0% to 100%
If you don't want the player to be able to switch back to 100% again, use BobStanley's method)
When GreenFlag clicked
Set volume to 100%
When m key is pressed
Set volume to ((abs of ((volume / 100) - 1)) * 100) %
Abs means absolute value.
Plug in 100% and 0% to see how it works.
Hope I helped!

(EDIT: This switches the volume back and forth from 0% to 100%
If you don't want the player to be able to switch back to 100% again, use BobStanley's method)
Last edited by dracae (June 5, 2013 12:53:23)
- BobStanley
-
100+ posts
Help with music!!!
When m key is pressed
Set volume to (0%)
Set volume to (0%)
Last edited by BobStanley (June 5, 2013 12:49:47)
- RUBIXS
-
60 posts
Help with music!!!
Try this:
When GreenFlag clicked
Set volume to 100%
When m key is pressed
Set volume to ((abs of ((volume / 100) - 1)) * 100) %
Abs means absolute value.
Plug in 100% and 0% to see how it works.
Hope I helped!
(EDIT: This switches the volume back and forth from 0% to 100%
If you don't want the player to be able to switch back to 100% again, use BobStanley's method)
Where is the absolute value thing???
- ImagineIt
-
1000+ posts
Help with music!!!
It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero. Glad we could help!
Here's a picture to clarify:
- dracae
-
1000+ posts
Help with music!!!
It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.
Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…

Especially with the amount of variables I use in the first place! XD
- RUBIXS
-
60 posts
Help with music!!!
It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.
Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…
Especially with the amount of variables I use in the first place! XD
Yeah… I already have 25+ variables

- dracae
-
1000+ posts
Help with music!!!
It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.
Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…
Especially with the amount of variables I use in the first place! XD
Yeah… I already have 25+ variables
Of course we aren't saying variables are bad or anything!
Variables are the essence of a powerful project.
- Discussion Forums
- » Help with Scripts
-
» Help with music!!!