How do you make a button call a sound?

I would like to know if any one knows how to make a button call a sound file that is inside of a procedure. I am trying to make a Yahtzee game and want a ROLL button to play a dice sound when clicked and I can't seem to get it to work. Can anyone help?

Please show your relevant blocks

You requirement is quite straightforward....

In the button click event, set the source for your sound in sound component or player, then call the sound component or player to start.

These are what I'm using but I can't think how to put the call block in the button selector. Also Is there a way to make the do procedure block work instead?

For example ?

image

image

How did you get the set Sound1 block?

Drag the sound component out onto the designer screen
Then use the blocks provided

Note: a sound component will only play @4-5 second files

Thank You!

1 Like

No need to start with two slashes: //

grafik

This is only needed for the File component, if the FileScope is set to Legacy and you want to access a file from the assets. There is no other component that uses (needs) it.

1 Like

Screenshot 2025-01-28 5.46.24 PM
I am creating a mini game called the two button game where you click on either on the Left or Right Button to get a point on the counter below. However, when I was adding a sound effect to the buttons, it wouldn't let me. I saw your posts but it didn't help. Above or below this message is the game and blocks of code that I used to make the game.

Fix the red errors, and in case it still does not work, then then provide another screenshot

Taifun

Here are the basics

minigame.aia (20.4 KB)

The red x's on the code say "duplicate event handler for this component". I don't know why that happens. TIM I tried using your code but it ended saying "Error 703 Unable to play". Below are the error and the duplicate event handler for this component issues.
Screenshot 2025-01-28 6.35.41 PM
Screenshot 2025-01-28 6.49.49 PM

Btw the blue triangles with white exclamations in the middle are errors

You only can have one LeftButton Click event, same for all other events

Taifun

I do have one left button click event. The other button click events are for the right button and reset button.

OmI only can comment on your first screenshot... unfortunately you did not provide an update

Taifun

sry here's a screenshot
Screenshot 2025-01-28 8.18.17 PM

Maybe you need a Player to play an mp3 file instead of a Sound component?

k what do i do from here? the play sound events and screen 1 events were deleted as a result of the deletion of the Sound1 component

Swt the source before playing
Use the Sound or the Player component

And yes, if you delete a component then all corresponding blocks will be removed

Taifun