How do you find the audiofileName in a sound that has been created?

Hi, I’m trying to add audio files to a table and whenever a button is pressed, it checks to see if the audio is already stored (to prevent duplicate loading of the same file), but I haven’t been able to find a way to accomplish this.

local found = false -- Audio hasn't been found yet. local soundNum for i = 1,#Sounds do if (Sounds[i].audiofileName == soundLocation) then -- If audio has already been played. Error appears here. found = true soundNum = i -- table value to play. break end end

This returns “attempt to index field ‘?’ (a userdata value)” when I try to compare the audio’s location to the location of the new audio.

I’ve also tried assigning a value like Sounds[1].location = audioLocation and comparing those values, but this gives a similar problem.

Any help would be appreciated.

Although it is possible to give you many suggestions, not knowing how you’re making your buttons, and what your list of sounds is, it is hard to answer.

You might be better served zipping up your project and attaching it here for folks to look at and then to give suggestions.

Ah, I see. I was trying to store audio in a table to reduce future load times, but disposing and reloading audios every time doesn’t take long to load, even on old phones, so I’ll just do it that way. Thanks for responding so fast though.

Although it is possible to give you many suggestions, not knowing how you’re making your buttons, and what your list of sounds is, it is hard to answer.

You might be better served zipping up your project and attaching it here for folks to look at and then to give suggestions.

Ah, I see. I was trying to store audio in a table to reduce future load times, but disposing and reloading audios every time doesn’t take long to load, even on old phones, so I’ll just do it that way. Thanks for responding so fast though.