# Scripting API: Checking if an audioFile object is valid

**URL:** https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901
**Category:** FMOD Studio
**Tags:** javascript, studio-scripting-api
**Created:** [January 15, 2026, 11:21pm UTC](https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901 "2026-01-15T23:21:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CaioMJ](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@CaioMJ](https://qa.fmod.com/u/CaioMJ)
#### Post date: [January 15, 2026, 11:21pm UTC](https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901/1 "2026-01-15T23:21:51Z")

</div>

Hello,

I’m writing some automation with JavaScript using the Scripting API. One of the things I’m doing is iterating through all events in my FMOD project and getting a list of all audio assets referenced by an event, however I’m running into an error when getting an asset from an event that has an instrument with no assets assigned.

Code snippet:

```javascript
for( var j = 0; j < instruments.length; j++ )

{

     if( instruments[j].entity === "SingleSound" )

     {

     sourceFileList.push( instruments [j].audioFile.assetPath );
     }

```

}

How can I check if the `audioFile` or the `audioFile.assetPath`are valid? Adding an if statement to check if `audioFile != null` (nor checking if audioFile.assetPath != null) have not worked so far.

Best,

Caio

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [January 29, 2026, 5:37am UTC](https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901/2 "2026-01-29T05:37:58Z")

</div>

Hi,

I unfortunately haven’t been able to reproduce the behavior you’re describing. Standard `!= null` checks on `audioFile` and then `audioFile.AssetPath` work as expected on my end. Could I get your exact FMOD Studio version, as well as a complete script that reproduces the issue you’re describing? Also, what is the specific error that you’re receiving from Studio when this happens?

As an aside, if they exist/aren’t `null`, all `ManagedObjects` also have an `isValid` boolean property you can check to ensure the object’s properties are internally consistent.

---

<div class="post-metadata">

### Author: ![CaioMJ](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@CaioMJ](https://qa.fmod.com/u/CaioMJ)
#### Post date: [January 30, 2026, 4:53pm UTC](https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901/3 "2026-01-30T16:53:59Z")

</div>

I just realized I was checking for `[null]`instead of just `null `for some reason (don’t ask me why lol) so now it works. Good to know about `isValid` tho, thanks!

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [February 6, 2026, 2:37am UTC](https://qa.fmod.com/t/scripting-api-checking-if-an-audiofile-object-is-valid/23901/4 "2026-02-06T02:37:38Z")

</div>

Happy to hear that you resolved the issue!
