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.