What do you want to achieve?
I want to achieve a loading screen that has a little progress bar at the bottom. I have made most of the screen. What is the issue?
I can’t find a way to do it without making a big script using lots of Frames.
You’re making everyone wait for 15 seconds no matter they have loaded or not. That’s now how it works. If someone loads after 5 seconds, the loading screen should get off.
This method might help:
@pranvexploder has a good point about loading, though it may take a long time to wait for the game to fully load. In terms of making the bar, you can use TweenService or GUIObject:TweenSize to re-size a frame which is a child of your background frame using UDim2.new(percentage/100,0,1,0) where percentage is a number from 1-100.
I would take a look at this post if you’re looking for a progress bar that updates correctly by using PreloadAsync on the various things needed to be loaded in.
But don’t go out of your way to ensure 100% of assets are loaded since this is rather inefficient. You are better off just checking if cruical assets are ready like the GUI and important models in the workspace
If you want a progress bar just make an empty frame as the back ground and make the actual frame that will be loading and then make it as small as possible the actual loading frame and then in a script just
do a repeat until the size of the actual loading frame is the size of the background frame the actual loading frame is on and just tween the size to the size of the background of the loading frame and make sure to put the repeat until below the tween
That would perform the check only once, and it would obviously return false because your game can’t load in such a small amount of time.
Try this:
script.Parent.Enabled = true --Initially enables the loading screen
print ( "Loading game..." ) --Prints that the game is loading
repeat wait() until game:IsLoaded() --Waits until the game loads
script.Parent.Enabled = false --Finally makes the loading screen to disappear
Alright, so how would you determine the tween duration?
Another thing with your idea is that even if I know the duration, the bar would tween uniformly, hence making a “fake” loading bar. We want an actual loading bar, that would increase its size in X when the assets actually load. PreloadAync() in a loop, providing all the assets one by one, will load all the assets, and will give you a count of the assets loaded, and the assets remaining to load. This is enough for you to tween the bar’s size.
Like how you’d need to disable the default chat for making a custom chat, disable the default backpack to make a custom backpack, and disable the custom player list to make a custom one, you’d need to disable the default loading screen for your custom loading screen to show up. Here is the documentation of it: ReplicatedFirst | Documentation - Roblox Creator Hub