Sound Play Limitations?

ive recently been working on adding a sound system and have uncovered a strange phenomenon.
(i have 2 independent sound systems playing, one for playing tracks in a loop, and one for making gui noises for things like mouse enter)

whenever i trigger the GUI noises too quickly in succession (Eg in bulk),
I notice that the independent music track stops prematurely.
(and its random weather you can then hear even the sound effects).

This leads me to believe that there is some limit to soundtracks being played in a game at any one time. (or maybe just overloaded?)

the music does not change status, or resume.
image

image
the cutoff seems to be maybe around 25 ish ?

my current dual sound system

image – the background music player

– the sound effect player

all guis go to the same bindable.
also an example of the gui code

(after a small period the sound efefcts work again, i assume because they are “fresh” clones.
but then somehow the music system was messed up).
i made this addition
image
but it does not activate either when the sound stopps.
further making me believe this is perhaps unintentional.

even more strange, after a relatively long time,
the music track starts again (from the beginning)
meaning that it still gives the ended event and resets the loop.

strange …
(i also got this error
image but im pretty sure its unrelated.)
so here it is.
have i discovered a roblox cap, a practical limit, or have i made some mistake ?

(also forgot to say this)
this is all in a signle script that is clientsided

2 Likes

the only solution i can think of is a throttle based an a self imposed hard cap so the background music will alwase play. (that of-course assumes that there is some kind of limit)
but im not even sure how to micro-throttle for snappiness but no spam.

maybe a delay …
so like when you press the button, its a delay befoe it makes the out sound and you are able to do the in sound again…
(would throttle and help if its just a (limit per moment) kind of thing)

What kind of phenomenon are we talking about actually? Is the problem that multiple pieces of music are playing at the same time? Because MouseEnter can fire event multiple times because of overlapping.

the phenomenon as stated above is that all existing sound stops outputting audio (while stile “playing”)
i use a co-routine duplicate so there would theoretically be no limit to the amount of sounds played.
each sound is an independent thread.

(time step still increases)
image

(now that i think about it, is there a thread limit ?,
then again a thread limit wouldent stop the music track …)

all im saying about the overlap is that it may be causing some issues. (but i dont know)

You can use flags to prevent overlapping here is an example of how to do it:

local Flag = false

if Flag ~= true then
    Flag = true
    -- Do your thing
    Flag = false
end

The error you are getting Attempt to connect failed: Passed value is not a function shows up when you use an implemented function wrong in the studio. There also maybe is a thread limit as you stated because maybe it creates a big impact of performance on client or server-side if many sounds are played at the same time.

2 Likes

i have a system like that for other input,
the issue with using that for this would be that how quickly does it reset.
the user in some situations might still get no feedback.

because remember, i do multithreadding.
if i were to do it like this then there would be no (instead of a healthy “some”) overlap.
the interaction would be stuck to 1 gui until its sound is finished.

thats why i said microthreadding.

auctally.
i just realized i can “flag” the individual input from each button, feeding into the single use overlap!

thanks! :slight_smile:

but then that still leaves the question…
why did this happen in the first place,
and is it intended behavior…

There are many reasons why it might happened. Maybe because of overlapping the bindable event and sending request of sound to Roblox API was too much and Roblox just added the requests to queue or just deleted them. It’s intended behaviour if we look from this perspective because why would Roblox allow anyone to distract their servers with so many requests?

yeah but then why no error,
why no status change.
surely if they made this system it would pull the right strings to tell us …

also, why server requests ?
doesn’t it download the music once then use it ?

There maybe happened an error but not in the studio but on their servers. I do know that Roblox has many issues still with sounds and haven’t been fixed yet. I can still see some sounds counted as playing on the website (when I try to listen to them), but when I check the console of Google it gives me an error of a JavaScript.

again,
im pretty sure that once the game starts servers have nothing to do with it.
like i could temporarily go offline (in studio) and it should run just fine
(just tested, once the game loaded and sounds started playing, i cut off the internet, and sounds still played.
so yeah, only server communication as of current is at load time.
and i think only data-stores are limited anyways.

so then.
this still remains unexplained

also, even using the “flag” the error still happens
back to square one … :frowning:

i might rework the buttons to simulate being “pressed in” and see if that fixes it,
but this moves it away from spammyness…

Cloning the sound to all the players in the game is different theory than going offline and testing it alone. Again, the error you are getting Attempt to connect failed: Passed value is not a function shows up when you use an implemented function wrong in the studio this has nothing to do with flags, flags are only used to prevent overlapping.

i think you misunderstand.
all of this is happening on the client.

(the error only happened that one time by the way, and is unrelated i belive, and im pretty sure the error is when you say connect:function oh but its not a function)
the flags did work, just the issue still occurred.
(i think even with the flags its too fast, which is what i am adressing.)

Yeah MouseEnter is too fast and it’s overlapping anyway. Maybe try to change it to MouseButton1Down so the function will start once the player clicks on a button for instance.