Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a walking sound for a sprite with 2 seperate movement buttons?
- ToxicXL30
-
New Scratcher
2 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
I am currently making a 2d platformer and need help with some walking sounds
I have been advised to use the script below but because I have 2 movement options they just get in the way of eachother
Here is the script:
It's quite confusing because if I have 2 of these scripts running at the same time for the right arrow and the left arrow (my 2 movement options) the footstepps sound will always be playing for a split second and then restarting itself. Is there any way that I can make it so that:
When green flag clicked
forever
if <not <key right arrow OR left arrow pressed?>>then
stop all sounds
But the stop all sounds part is quite annoying because I also have a background music for my game, so if I or anybody else finds a solutionI will add to this question later.
*basically any movement button you choose
I have been advised to use the script below but because I have 2 movement options they just get in the way of eachother
Here is the script:
when green flag clicked
forever
if <key [ d*] pressed?> then
play sound [ footsteps] until done
else
stop all sounds
end
end
It's quite confusing because if I have 2 of these scripts running at the same time for the right arrow and the left arrow (my 2 movement options) the footstepps sound will always be playing for a split second and then restarting itself. Is there any way that I can make it so that:
When green flag clicked
forever
if <not <key right arrow OR left arrow pressed?>>then
stop all sounds
But the stop all sounds part is quite annoying because I also have a background music for my game, so if I or anybody else finds a solutionI will add to this question later.
*basically any movement button you choose
Last edited by ToxicXL30 (March 5, 2023 11:37:05)
- Oxygen485
-
Scratcher
14 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
I think this can work.
when green flag clicked
forever
if <key [ d] pressed?> then
set volume to (100) %
play sound [ footstep] until done
else
set volume to (0) %
end
Last edited by Oxygen485 (March 5, 2023 12:29:24)
- is38aac
-
Scratcher
39 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
I am currently making a 2d platformer and need help with some walking sounds
I have been advised to use the script below but because I have 2 movement options they just get in the way of eachother
Here is the script:when green flag clicked
forever
if <key [ d*] pressed?> then
play sound [ footsteps] until done
else
stop all sounds
end
end
It's quite confusing because if I have 2 of these scripts running at the same time for the right arrow and the left arrow (my 2 movement options) the footstepps sound will always be playing for a split second and then restarting itself. Is there any way that I can make it so that:
When green flag clicked
forever
if <not <key right arrow OR left arrow pressed?>>then
stop all sounds
But the stop all sounds part is quite annoying because I also have a background music for my game, so if I or anybody else finds a solutionI will add to this question later.
*basically any movement button you choose
I know how to make this work, ill make a showcase in a sec
- is38aac
-
Scratcher
39 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
I think this can work.when green flag clicked
forever
if <key [ d] pressed?> then
set volume to (100) %
play sound [ footstep] until done
else
set volume to (0) %
end
end
The issue with this script is that the “play sound until done” hast to end before it can register the “else” command so it would be the same effect
Last edited by is38aac (March 5, 2023 13:31:40)
- is38aac
-
Scratcher
39 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
I am currently making a 2d platformer and need help with some walking sounds
I have been advised to use the script below but because I have 2 movement options they just get in the way of eachother
Here is the script:when green flag clicked
forever
if <key [ d*] pressed?> then
play sound [ footsteps] until done
else
stop all sounds
end
end
It's quite confusing because if I have 2 of these scripts running at the same time for the right arrow and the left arrow (my 2 movement options) the footstepps sound will always be playing for a split second and then restarting itself. Is there any way that I can make it so that:
When green flag clicked
forever
if <not <key right arrow OR left arrow pressed?>>then
stop all sounds
But the stop all sounds part is quite annoying because I also have a background music for my game, so if I or anybody else finds a solutionI will add to this question later.
*basically any movement button you choose
Aight, i made the showcase. Here you go —> https://scratch.mit.edu/projects/813836034/
I hope this helped you with your game

Last edited by is38aac (March 5, 2023 13:41:57)
- ToxicXL30
-
New Scratcher
2 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
@Oxygen485 and @is38aac
Thanks so much for the help! Especially the showcase because it shows what happens in an actually running script in game. This will help so much with my game now!
Thanks so much for the help! Especially the showcase because it shows what happens in an actually running script in game. This will help so much with my game now!

- is38aac
-
Scratcher
39 posts
How do I make a walking sound for a sprite with 2 seperate movement buttons?
@Oxygen485 and @is38aac
Thanks so much for the help! Especially the showcase because it shows what happens in an actually running script in game. This will help so much with my game now!
glad to help- Discussion Forums
- » Help with Scripts
-
» How do I make a walking sound for a sprite with 2 seperate movement buttons?


