Sound doesn't play when using :Play()

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.

Here is a copy of the file: SoundBug.rbxl (19.6 KB)

Thank you for your time reading this post and trying to help me out. I really appreciate it.

7 Likes

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.

edit: try this instead of using Debris:

sound.Ended:Connect(function()
    sound:Destroy()
end)

Works on my end.

2 Likes

I clone an existing sound then play the clone

I remove the clone using game.Debris using the length of the sound right after the IsLoaded variable is set to true.

I did think that it could be an issue so I had removed the removal part in general, and the issue persisted

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
7 Likes

I’ll test it out in a bit, thank you for your input

1 Like

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?

3 Likes

If you think, it’s a bug then go ahead to #platform-feedback:engine-bugs and report it, there.

1 Like

Sorry for the delayed response. We have filed a bug for this and the engineers are working on it. As soon as there is any updates i will pass it on

11 Likes

Still same trouble, spend 40 Robux on 2 audios, not working at all.

This bug is being looked at by engineering. When there is an update i will pass on that info.

Thank you for submitting a bug report. I am not that accustomed to the Developer Forums and I have no idea how everything works here.

1 Like

Are there any updates on this bug? I’m still running into this issue.

5 Likes

I am having the same issue. Why can’t something as simple as playing audio work? Lol

This worked for me! The difference between your code and mine is I put my sound in the player character.

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! :smiley:

5 Likes

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

3 Likes

Still an ongoing issue. Instead of sweeping this bug under the rug, can it get fixed please?

have you tried this instead?

SoundHere.Playing = true