So I have a coin giver module that gives players a certain amount of coins when a function inside of it is called. Just to make things look and feel better, I also hooked up an Event that fires when the giver function from the module runs. That event does nothing else than play a sound a couple of times per second inside the client script. What I’ve found out is that most of the times the sound doesn’t play.
Essentially, the issue is that the sound doesn’t play at all when calling :Play()
I’ve tried many things, reparenting the sound to other objects like SoundService, Workspace, PlayerGui, waiting until the sound loads, not using SoundGroups, etc. Nothing worked though…
Hell, I even thought that the issue is in Studio itself, so I tried testing it in-game and still had the issue.
Here is a video of the problem: (Sound on)
As how you may have noticed, every time I run the :Play() function, I also print out yes and 0.5.
The rate at which this code runs is 30 time a second and you can clearly see that the sound doesn’t play at this rate, not even close.
I am desperate for a fix, been trying for almost an hour now and I have no idea whatsoever on what the issue might be.
Are you playing the same sound over and over or a different sound? If it’s the same sound, you’ll only ever hear the first 1/30th of a second of the sound, which may be silent - this is because :Play() resets the TimePosition of the sound to 0.
If you’re using one sound per event, are you deleting the sound before it’s finished playing? That would cut the sound short.
Interesting. Have you tried replacing :Play() with .Playing = true? If not that, what about using RunService.Stepped instead of a while wait() do loop?
Not sure if that would make a difference; this seems like an engine bug.
If the sounds are played outside of the workspace and don’t need to loop, I recommend using SoundService:PlayLocalSound instead. This method lets you play a sound multiple times at once without cloning it.
Here’s what it might look like when implemented into your code:
function module.PlaySoundUI(id,volume,speed)
volume = volume or 1;
speed = speed or 1;
-- looped = looped or false; (Looping doesn't seem to work with PlayLocalSound)
local sound = script:FindFirstChild(tostring(id));
if sound then
sound.Volume = volume
sound.PlaybackSpeed = speed
game.SoundService:PlayLocalSound(sound)
else
warn('Sound doesn\'t exist');
end
end
I just tested it this morning, still doesn’t fix it. I am thinking that it might be an issue with the actual sound file. It was initially uploaded as an .ogg file which could be an issue
Found the issue.
If the length of the sound file is shorter than half a second, the sound engine just bugs out completely and doesn’t play it anymore. This is extremely strange, do you guys know of any way that I could report this bug?
It has something to do with the Sound Framework inside of Roblox. If your sound is 0.1 seconds long, add a 0.9 silence section to the end of your track so that the total time is about 1 second, it should work fine after that!
Any info passed through?? Been several months with no word. As OP mentioned, seems to happen if sound is a small length. Problem with their solution is if you are using sounds that from the marketplace, where you don’t have access to the original files