Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you prevent the huge lag spike when songs change?

Whenever I start a new audio for the first time, there's a large lag spike. My entire screen freezes for a few seconds.

I tried preloading the sounds, but it did not makes a difference.

I was wondering if there was any way to prevent this lag. I will not post my code, because it works fine, all I need to know is if this is possible, and if so how to do it.

1 comment

0

I'm not too sure, I think it has to do with a Audio's Length, because, I used a 15-second long Audio, and it didn't lag for very long, but when I used a 1-minute long one, it lagged for more than 5+ seconds, so, there's nothing we can really do about it sadly. :/

1 answer

This is actually quite simple to do! Roblox implemented some API in order to Preload assets, like sounds and images, so that it doesn't have to in the future (why you get the lag spikes).

local ContentProvider = Game:GetService("ContentProvider")
 
local assetList = {} -- I suggest creating a table of asset ids (Ex: 130758889)

for _, assetId in pairs(assetList) do
	ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. assetId)
end

3 comments

0

Read his second paragraph. I know from experience that preloading the sounds doesn't stop the lagspike when they start playing.

0

Yeah unfortunately preloading doesn't work.

0

Sorry, I missed that part

This discussion is preserved as it was. New answers, comments, and votes are closed.