Playing a sound by any means and PlayOnRemove have a ~0.1 second delay

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix the fact my audio clips that have been trimmed have a ~0.1 second delay in Roblox only

  2. What is the issue? Include screenshots / videos if possible!
    Watch 2024-05-08 19-47-13 | Streamable Vid of the issue

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for solutions here. I’ve tried locally playing it with SoundService and I’ve tried not playing it via PlayOnRemove. I’ve also tried IsPlaying and :Play()

Here’s all 3 of the shirt cloth sounds from the video. You’ll notice that there’s no delay

Let me know if there’s anything I can clarify to help. I didn’t really know what else to add. I know nothing is yielding the script before the sound plays because
A) The sound is played before switching the clothing
B) The sound is handled in another script. It cant be yielded


Are you certain this isn’t just placebo?
It’s hard to tell in the video, since I am not the one clicking my mouse, but there doesn’t appear to be any delay.

I’m relatively certain
You can tell when I click by the clothing changing. The clothes changing is immediate

Are you loading the sound each time you play it, or is the sound already loaded and you just sound:play() or sound:stop() it when needed?

It’s loaded the first time it’s played
But either way when they’re all loaded they still have a ~0.1 second delay rip

As a test can you just make the sound play in the first script instead of the ‘other’ script to see if that makes a difference.

Yeah the same thing happens sadly. That was why I moved to a second script to see if it’d fix itself

You can try setting the TimePosition of the sound to 0.1 seconds so it starts from later in the sound itself. That’s only if it’s the audio though

Yeah no luck sadly. Same 0.1 seconds delay it just starts closer to the end

You mention that the sounds are already loaded right?
And you mention that you are playing them with PlayOnRemove?
How’s that? So the sounds, bunch of them already exist and loaded in an instance? SoundService? where? and you want to play them when removed, when all sounds got removed you dont clone them and place them again?

Why not having the sound loaded only one per each different sound and play them as needed without remove them?

I found the solution! It was instantiating / cloning the sound although it never yielded
The only reason I cloned the sounds was so there was no cutoff when it was spammed. Here’s my new setup

        if curRandomSound then
			curRandomSound = utils.VariedSound(sounds, curRandomSound)

			curRandomSound = sounds[math.random(#sounds)]
		game:GetService("ReplicatedStorage").SFX:FireAllClients(script.Parent.Parent.Sound, curRandomSound)

I send a remote indicating the sound I was to play and a new ID
The client receives this and uses soundservice to play is locally

repStorage.SFX.OnClientEvent:Connect(function(sound, id)
	local curID = sound.SoundId
	sound.SoundId = id
	sound.SoundId = curID

Playing it locally also doesn’t have any cutoff for some reason


I was originally cloning a template sound and then destroying it instantly

Actually this was the key of your issue, in which you replied you were not, and those were already loaded, but you were cloning them

Thats why I replied to this comment from yours:

Which I knew it was wrong.

Glad you found it, happy coding!

Okay so turns out this only fixed it for a while for some reason
I now load all audio IDs prematurely and that doesn’t seem to have fixed it. I don’t instantiate stuff anymore

…Nevermind?? It just doesn’t work in Studio but works in the actual game

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.