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
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.
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)
else
curRandomSound = sounds[math.random(#sounds)]
end
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
game:GetService("SoundService"):PlayLocalSound(sound)
wait(sound.TimeLength)
sound.SoundId = curID
end)
Playing it locally also doesn’t have any cutoff for some reason
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