-
What do you want to achieve? Keep it simple and clear!
i made a combat system and i have a module with alot of useful functions that follow the “dont repeat yourself” rule thing soo i dont have headaches and i want to detect when a sound ends without hacky or deprecated methods -
What is the issue? Include screenshots / videos if possible!
i searched in alooooooooot of threads for help and none worked as expected rn
here is the current code i made as placeholder while i wait for the answer
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yea and didn’t find a solution for my problem yet
To wait for a sound to end, you can call Sound.Ended:Wait()
. If the sound is playing it’ll wait for it to finish. I’d suggest wrapping that in
if Sound.Playing == true then
Sound.Ended:Wait()
end
to make sure you aren’t waiting for a sound that’s already finished.
i already tried sound.ended but it fires before the sound ends giving me odd issues of the hit sounds playing for like 0.1 seconds
To my knowledge using :Wait() never actually stops the sound, are you sure nothing else prematurely destroys/stops/pauses the sound?
Another possibility is that I’ve noticed that sounds played in quick succession are sometimes stopped without reason, I’m assuming to prevent loud overlapped audios. Are the hit sounds played frequently?
they are played everytime the player hits the person (every 0.5 seconds i suppose) and their pitch is 1.2
also i just tested here using sound.Ended:Wait() instead of sound.Ended:Connect(function() and it yields the script infinitely and doesn’t destroys the sound
I’m genuinely lost here,
if Ended
fires before the sound ends, it might be worth filing a bug report since it’s inaccurate and could cause some glitches in some games. (like in your case)
ive found in the forum that someone said roblox had reworked sounds and it was what broke most sound events soo idk what to do since theres prob like 10000000+ bug reports already
I’d leave it a little while to see if any more reports crop up about it.
I do use Ended:Wait()
a fair bit, but I don’t rely on it being 100% accurate. I have noticed some delays when waiting for music to stop, though. I thought it was just latency.
sound.Ended:Connect(function()
sound.IsPlaying = false
end)
i checked here and ur method actually deletes the sound after it stops and i think it infinite yielded my script rn due to my animation event checking thing soo imma mess around here and fix it
but its still odd that using :Connect(function() instead of :Wait() makes the event fire before the sound ends, but i guess imma stick to :wait() from now on, thx for the help
Do you create the sound and play it on the server or the client?
Do you wait for Ended to fire on server or client?
When Ended fires on the server may not be when it fires on the client, as there may be a delay in playing the sound as the sound is loaded over the network.
i do everything in the server after i found out that i cant trust the client at all
that makes sense cuz i just tried the wait() method rn and it stopped working again and its now firing the event before playing again
i will try checking if the sound stops playing manually using playing value in the sound
ok that didn’t work soo i tried mixing sound.ended with a wait() ik its not reliable but i guess i will use that until i find a better method