generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

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

Previous Thread :: Next Thread 
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
20 Oct 2014 06:13 PM
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.
Report Abuse
builderman0621 is not online. builderman0621
Joined: 13 Jul 2010
Total Posts: 1612
20 Oct 2014 06:13 PM
You really cannot, sorry.
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
21 Oct 2014 08:35 AM
aaaaawwwwwwwww
Report Abuse
builderman0621 is not online. builderman0621
Joined: 13 Jul 2010
Total Posts: 1612
21 Oct 2014 08:49 AM
Try preloading them.

http://wiki.roblox.com/index.php?title=Preload
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
21 Oct 2014 09:03 AM
@builderman:
"I tried preloading the sounds, but it did not makes a difference."

Read before you post.

-The [Guy]
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Oct 2014 09:14 AM
You can "fake" preload them by playing and immediately pausing them all when the player joins. This will cause the client to load them in even though the song doesn't have enough time to actually play.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
21 Oct 2014 10:12 AM
You need to make sure that the computer like, actually caches them properly (Ready to read instead of being ready downloaded), otherwise the lag caused will probably be from the reading of the file (It holds up the main thread until it's done)

Something like that anyway, if it's anything like stuff I've used in the past
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
21 Oct 2014 11:00 AM
Preloading them does make a difference, if it's still lagging, you're either not preloading correctly or you have a terrible processor.
-=Robo=-
Report Abuse
builderman0621 is not online. builderman0621
Joined: 13 Jul 2010
Total Posts: 1612
21 Oct 2014 01:16 PM
@Busy
He obviously didn't do it right, lrn2swag before you post.
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
21 Oct 2014 03:02 PM
I didn't do it right??? Here's my code. It's a server script inside of ServerScriptServer. All the ID's are correct.

It actually DOES make a difference when I do it on Play Solo, but I still get the huge lag spike when I play online.

local assets = {144941795,163233363,178847457}

for _, asset in ipairs(assets) do
game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
21 Oct 2014 03:09 PM
Actually with more tests I get the huge spike in PlaySolo as well.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
21 Oct 2014 03:23 PM
Try using my idea. It works in my game as I had the same problem with preload.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
21 Oct 2014 05:39 PM
Are you playing the songs immediately? All preload does is queue them in roblox's content loader. It doesn't actually load them. It'd be the same as playing the audio, it'd freeze the game until the client successfully downloaded the asset.
In other words, if you're not waiting for it to finish loading, it's gonna do this. lol

-=Robo=-
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
22 Oct 2014 09:26 AM
@robocu
No I'm waiting a few seconds to allow them to preload.

@tinarg
That seems to work but when I do

sound:Play()
sound:Pause()

sometimes it doesn't pause. I'm not sure why, but maybe it's changing it so fast that it doesn't pause correctly. I tried putting a wait() between the lines, but then you can hear the sounds a little before they're stopped again.
It does get rid of the lag spike though.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Oct 2014 09:47 AM
'I didn't do it right??? Here's my code. It's a server script inside of ServerScriptServer. All the ID's are correct.'

that's your problem
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
22 Oct 2014 09:48 AM
^
do it in a localscript m8
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Oct 2014 09:52 AM
^
Report Abuse
Looah is not online. Looah
Joined: 22 Feb 2013
Total Posts: 922
22 Oct 2014 10:01 AM
^
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
22 Oct 2014 10:02 AM
^
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
22 Oct 2014 10:03 AM
Unfortunately putting that same code in a LocalScript in StarterGui didn't make a difference with the lag.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
22 Oct 2014 10:16 AM
http://wiki.roblox.com/index.php?title=API:Class/ContentProvider/Preload

Read the note

"And how high can you fly with broken wings? " - Aerosmith
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
22 Oct 2014 10:28 AM
Don't use dial-up
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
22 Oct 2014 03:18 PM
Well tinarg's idea ended up working the best. I just don't think preloading is getting me anywhere.

Thanks for all the help, everyone.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image