# API Studio Scripting: play a sound when build is complete

**URL:** https://qa.fmod.com/t/api-studio-scripting-play-a-sound-when-build-is-complete/19248
**Category:** FMOD Engine
**Created:** [September 7, 2022, 10:04pm UTC](https://qa.fmod.com/t/api-studio-scripting-play-a-sound-when-build-is-complete/19248 "2022-09-07T22:04:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![GiacomoF](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GiacomoF](https://qa.fmod.com/u/GiacomoF)
#### Post date: [September 7, 2022, 10:04pm UTC](https://qa.fmod.com/t/api-studio-scripting-play-a-sound-when-build-is-complete/19248/1 "2022-09-07T22:04:00Z")

</div>

Hi there,

I am looking to write a very simple js script that can play an FMOD Studio Event after having built banks (a notification sound of sorts).  
I have got the build banks working but I don’t understand how the Event.play() function works. The reference manual doesn’t give much away, at least given my limited experience with coding and javascript.

Can anyone help? Thank you 🙂

Btw, in the example below I am simply trying to adapt a script I found online to make it play a sound.

> var eventID = “{280ded2a-2a06-47c0-b8e5-ff197563243d}”;  
> var event = studio.project.lookup(eventID);
> 
> function doBuild() {  
> console.log(“Build started”);  
> studio.project.build();  
> Event.event.play();  
> console.log(“Build finished”);  
> }
> 
> var buildAndPlaySound = {  
> name: “Automation”,  
> execute: function(){ doBuild(); }  
> };
> 
> var automationMissing = true;  
> var menuItems = studio.menu.menuItems();  
> for (var i = 0; i \< menuItems.length; ++i) {  
> if (menuItems[i].name == buildAndPlaySound  
> .name) {  
> automationMissing = false;  
> break;  
> }  
> }
> 
> if (automationMissing) {  
> studio.menu.addMenuItem(buildAndPlaySound  
> );  
> }  
> else if (studio.system.question(“Do you want to build?”)) {  
> doBuild();  
> }

---

<div class="post-metadata">

### Author: ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)
#### Post date: [September 8, 2022, 3:31am UTC](https://qa.fmod.com/t/api-studio-scripting-play-a-sound-when-build-is-complete/19248/2 "2022-09-08T03:31:51Z")

</div>

You almost have it- you need to have the event selected to be able to play it back;

```javascript
function doBuild() {
    console.log("Build started");
    studio.project.build();
    var event = studio.project.lookup("event:/UI/Okay");
    studio.window.triggerAction(studio.window.navigateTo(event));
    event.play();
    console.log("Build finished");
}

```

---

<div class="post-metadata">

### Author: ![GiacomoF](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GiacomoF](https://qa.fmod.com/u/GiacomoF)
#### Post date: [September 8, 2022, 2:58pm UTC](https://qa.fmod.com/t/api-studio-scripting-play-a-sound-when-build-is-complete/19248/3 "2022-09-08T14:58:31Z")

</div>

Many thanks Jeff,

that worked!
