# Sound Randomizer

The example script, \_Sound Randomizer (\_*SoundRandomizer.cs),* plays randomly from a list of sounds at randomized intervals. You can get the file from the download link at the end of this article.

Instructions

Here is a step-by-step guide to using the script:

1. Download the script file from the download link at the end of this article.
2. Follow the instructions provided in [Working with scripts](/latest/creating-in-sansar/working-with-scripts.md) to upload the script and add it to an object.
3. Open the object's Properties panel and go to the Script Settings section.
4. Look at the Script Settings section on the Properties panel. Make sure that the script dropdown menu is set to the *SoundRandomizer* example script. If the script is set correctly, a set of editable parameters appears. See below for a short guide on each parameter.
5. Once you have finished setting the parameters for your object, your script is ready! Save and build your scene.
6. If you want to verify that the script is running correctly, visit the scene once it is built.

Script parameters

| ![SoundRandomizer.PNG](https://i3.wp.com/help.sansar.com/hc/article_attachments/115010856926/SoundRandomizer.PNG) |
| ----------------------------------------------------------------------------------------------------------------- |
| Parameters for Sound Randomizer.                                                                                  |

|                       |                                                                                                                                                                                                                                                                                                                                        |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PlayOnAudioComponent  | If your object has an [AudioComponent](/latest/script-api-docs/sansar-simulation-namespace/audio-component.md), setting this to "On" causes the sounds to play on the object. The sounds also follow the object if the object moves around. Otherwise, the sounds play directly to your speakers/headphones (like Sansar's UI sounds). |
| MinDelayBetweenSounds | The delay between each sound is randomized to fall into this range. If you leave them set to zero, there is no delay between sounds.                                                                                                                                                                                                   |
| MaxDelayBetweenSounds |                                                                                                                                                                                                                                                                                                                                        |
| Sound1                | Assign any of these slots to sounds in your inventory. You do not need to assign all of them. The script plays from the slots that have been assigned.                                                                                                                                                                                 |
| Sound2                |                                                                                                                                                                                                                                                                                                                                        |
| Sound3                |                                                                                                                                                                                                                                                                                                                                        |
| Sound4                |                                                                                                                                                                                                                                                                                                                                        |
| Sound5                |                                                                                                                                                                                                                                                                                                                                        |

[Creative Commons License](/latest/creative-commons-license.md)

Have more questions? Join our [Discord!](https://discord.gg/sansarofficial)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sansar.com/latest/script-api-docs/example-scripts/sound-randomizer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
