Play a random sound upon collecting coin

The problem is that the sound file parameter doesn’t work with strings, it’s another thing… not dynamic :frowning:
What you can do is play the sound with a simple JS code I wrote some time ago, here:
[url]How can I play sound files programmatically? [Solved] - #9 by Lizard-13]

var sound_manager = runtimeScene.getGame().getSoundManager(); // get the sound manager sound_manager.playSoundOnChannel("your sound dynamic filename string", 0, false, 100, 1); // play dynamic file sound, channel = 0, loop = false, volume = 100, pitch = 1
Put this code instead the action to play the sound, as a sub-event. The problem now is that you have to know JS to get the variable info from the scene:

var filename = runtimeScene.getVariables().get("SoundFilesStructure").getChild("variable name that contains a filename string")

Then you can use this value, read from a the scene variable array called SoundFilesStructure, and put it in the code to play a sound:

sound_manager.playSoundOnChannel(filename, 0, false, 100, 1);    // play filename sound, channel = 0, loop = false, volume = 100, pitch = 1

The idea of GD is no-programming, I know, but it’s a missing feature, so a give a workaround :neutral_face:

PS: In the link there is a C++ implementation too.