Okay, so I made a custom sound system that I made wait until the sound has finished playing using http://wiki.roblox.com/index.php?title=API:Class/Sound/Ended and the event only fires when the sound has finished playing... When the event is also supposed to be fired when :Stop()
is called on the sound (it even says it in the wiki)... But when I call :Stop()
on the sound the event isn't fired... And no it's not my script because it stopped playing the sound just fine. Is there something I'm doing wrong?... Why isn't this event working properly?
I need this event to also fire when :Stop()
is called so I can skip a sound that's currently playing without my script breaking.
If the .Ended
event doesn't work for you, you should use both .Ended
and .Stopped
events to tell whenever the audio stops or ends. Here's how you would use 2 events maybe:
local sound = script.Parent local function audioStops(audioId) -- insert your script stuff here end sound.Ended:Connect(audioStops) sound.Stopped:Connect(audioStops)
(Edit to answer comment below about making multiple events)
There's not such a great way of adding multiple events. The best way I can think of with waiting for both events with using :Wait()
is:
local sound = script.Parent local b = false delay(0, function() -- This makes it so the script doesn't yield while running this function. sound.Ended:Wait() b = true end) delay(0, function() sound.Stopped:Wait() b = true end) while true do wait() if b then -- insert script stuff end end