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()” 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
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%.
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.
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.
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 %
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.
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