Hi, I was making a loading screen, and after months of making simple loading screens, I decided I wanted to learn how to display the accurate percentage of the game being loaded in a GUI. I would like to know, is there a certain function, or method you can use to achieve this?
Based on roblox wiki, you should try to preload each asset at a time, yelding while it is loading:
01 | -- create some sample assets |
02 | local sound = Instance.new( "Sound" ) |
03 | sound.SoundId = "rbxassetid://301964312" |
04 | local sound 2 = Instance.new( "Sound" ) |
05 | sound 2. SoundId = "rbxassetid://301964312" |
06 |
07 | -- create a table of assets to be loaded |
08 | local assets = { |
09 | sound, |
10 | sound 2 |
11 | } |
12 |
13 | wait( 3 ) |
14 |
15 | for i = 1 , #assets do |
16 | local asset = assets [ i ] |
17 | ContentProvider:PreloadAsync( { asset } ) -- 1 at a time, yields |
18 | local progress = i / #assets |
19 | bar.Size = UDim 2. new(progress, 0 , 1 , 0 ) |
20 | end |