i need it to get to 5367 in 7 seconds but idk how
if i remove the wait the game just crashes
– i couldnt make a video cause file was to big
while true do
wait()
Time.Value = Time.Value + 1
script.Parent.AssetsText.Text = "Loading Assets"..Time.Value.."/5367"
if Time.Value == 5367 then
script.Parent.Parent.LoadingGui:Destroy()
end
end
wait() can only run at most 30 times a second, and can be throttled when the engine is slow.
This will interpolate over the course of 7 seconds by figuring out what the count should be based on how much time has passed.
local DURATION = 7 -- Seconds to complete
local TOTAL_COUNT = 5367
local startTime = os.clock()
while true do
local percent = math.clamp((os.clock()-startTime)/DURATION, 0, 1)
local count = math.floor(percent * TOTAL_COUNT)
local text = "Loading Assets "..count.."/"..TOTAL_COUNT
script.Parent.AssetsText.Text = text
if percent >= 1 then
break
end
wait()
end
script.Parent.Parent.LoadingGui:Destroy()
The fastest way you’d be able to count with something like that is either with task.wait() which will resume on the next update or renderstepped, as both of these update per frame. RenderStepped will be more reliable however I believe the best method is to just use VitalWinters method, it’s simple and works as a simple loading screen.
What’s the point in making an artificial loading screen like this? Your aim should be to get a player to jump into the gameplay ASAP, so your loading screen should realistically only be used so you can do some background prep or load assets that’ll be immediately visible by the player.
ContentProvider provides you a way to prioritise assets to be downloaded, so you could create a list of the instances you want downloaded first and then give an estimate as to how long that’d take. I do not personally recommend or endorse using RequestQueueSize for a loading screen though.
If you aren’t loading anything then no point in making a loading screen. Your loading screen should be dependent on actually loading in assets or preparing the game, not speedrunning a counter.