Loading Screen Help

So i am making a loading screen
and i gotta use
(i think)
repeat wait(.5) until game:Isloaded()

but we gotta get away that
the bar fills at same time
and it shows the % that loads
local GUI = script.Parent
local BackGround = GUI:WaitForChild(“BackGround”)
local LoadingScreen = GUI:WaitForChild(“LoadingScreen”)
local LoadingBar = LoadingScreen:WaitForChild(“LoadingBar”)
local Filler = LoadingBar:WaitForChild(“Filler”)
local Percentage = LoadingBar:WaitForChild(“Percentage”)

wait(5)

for i = 1,100 do
wait(0.05)
Percentage.Text = i…"%"

local Formula = i/100

end

i also have the script:
local PlayerGui = game.Players.LocalPlayer:WaitForChild(“PlayerGui”)
PlayerGui:SetTopbarTransparency(0)

local GUI = script.LoadingScreen:Clone()
GUI.Parent = PlayerGui

repeat wait(1) until game:IsLoaded()

GUI.Frame:TweenPosition(UDim2.new(0,0,1,0), “InOut”, “Sine”, 0.5)
wait(0.1)
GUI:Destroy()

2 Likes

“repeat wait(1) until game:IsLoaded()” i gotta make a way that whyle it loads the loading bar increases and same with the %, and that the amount of increase its the amount of % u know, i cant really explain it but yeah

1 Like

Why exactly are you making a fake loading screen? Using wait() in a repeat loop will stop the code from running under it until it’s finished. You could use coroutines, task.spawn() or task.defer() to make them run in “sync”. You would have to keep track if the repeat loop is still running while your loading bar is still going up. You would need some way to actually get the % of how many objects have been loaded yet, which you can’t just do with game:IsLoaded() because it just returns a boolean. So there is no way of knowing if it would be 10% out of the 100% or 59%.

2 Likes

The way i would do a loading screen is i would have models / folders in ReplicatedStorage, and when the game is loading, call them into workspace and wait for them to be loaded, and use the number of loaded items divided by the total number of items to determine how loaded the game is.

UI_Frame.Size = Udim2.new(LoadedItems / TotalItems, 0, 1, 0)

To get the number of items loading, you can use this:
game:GetService("ContentProvider").RequestQueueSize
You’ll then want to have that repeat until that number is 0.

So basically, your model with all items that need to be loaded gets put into workspace, and then the client waits for everything to be loaded, while displaying a bar of the actual progress.

-- This would be in a local script inside a ScreenGui
local LoadingItems = game:GetService("ReplicatedStorage"):WaitForChild('ItemsToLoad')

LoadingItems.Parent = workspace

local LoadingBar = --Loading bar frame

repeat
task.wait(1/15)
-- Range will return a number from 1 to 0
local Range = #LoadingItems:GetChildren() / game:GetService("ContentProvider").RequestQueueSize
LoadingBar.Size = Udim2.new(Range, 0, 1, 0)
-- If you have text that displays the percentage, just multiply the Range by 100, and then math.floor() it
until game:GetService("ContentProvider").RequestQueueSize <= 0

LoadingItems.Parent = game:GetService("ReplicatedStorage")

Im not sure how efficient this is though, however it should provide a good loading screen.

2 Likes

It’s a old post so don’t expect good code quality and english but it should still work.

1 Like

its not meant to be a “fake loading screen” i need to use the reapeat until game loaded but i gotta make with the animation and thoose stuff so as making it with the %

Thank you so much, i will test it!!!

Did you check this?

That’s what I’m using and it works very well.

1 Like

I have the loading screen done but now i need to make an animation with tween services but it needs to say % of loaded and to raise the bar

That’s another story. The example I gave is in the ReplicatedFirst, as it will be the first thing that appears to the player.
After that, your other modules will be loaded.
Also, if you want to show the loading %, you will have to tell this Gui which % you are in (as your game will depend on several factors to load, such as DataStore, objects, Gui, etc.
The example I provided is for a simple upload with no % tracking.

yeah, i wanted to check the % and show it that was it basicly, gotta try it i g
the “simple” loading screen i had it alrd kinda

Thank you, i will give a shot!!!

Hey, ive tested and gives me the error "Players.gachecem_YT.PlayerGui.LoadingScreen.LocalScript:2: attempt to perform arithmetic (sub) on nil "
but its exacly like the video that you showed at the other post, its exacly how i want it