How do I make a loading screen?

I just want to make a simple image that is a background and then when loading is done, I want a button to appear. I looked at YT videos and they all have like gradients, and huge scripts, and cameras. What’s a very simple way to make a loading screen?

1 Like

A simple way to make a Loading Screen should be that you set up your UI first and then do this which just waits for the game to load in:

game.ReplicatedFirst:RemoveDefaultLoadingScreen() -- "Removes" default loading screen

if not game:IsLoaded() then
game.Loaded:Wait()
end

After that you remove the UI, if you want you can add a wait


This Isn’t my code however, its the code Provided by Roblox:

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- Create a basic loading screen
local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true

local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(0, 20, 40)
textLabel.Font = Enum.Font.GothamSemibold
textLabel.TextColor3 = Color3.new(0.8, 0.8, 0.8)
textLabel.Text = "Loading"
textLabel.TextSize = 28
textLabel.Parent = screenGui

-- Parent entire screen GUI to player GUI
screenGui.Parent = playerGui

-- Remove the default loading screen
ReplicatedFirst:RemoveDefaultLoadingScreen()

--wait(3)  -- Optionally force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end
screenGui:Destroy()
2 Likes

so this would basically make it so a text label would say loading and then delete when the player loads?

Correct,

This Part as stated, forces the Load to wait 3 seconds, however this is an optional thing, if you dont add it, you may not even see it as the game loads fast

The solutions provided above don’t actually load well the game. if you’d like to make an screen that actually loads the game, use ContentProvider

Example Code:


local Frame = YOUR_PATH_HERE
local ContentProvider = game:GetService("ContentProvider") 
local Assets = game:GetDescendants()
local ReplicatedFirst = game:GetService("ReplicatedFirst")

-- removing the default loading screen

ReplicatedFirst:RemoveDefaultLoadingScreen()

-- here the game loads

Frame.Visible = true

ContentProvider:PreloadAsync(Assets) -- the script "yields" (stops) until all assets have been pre-loaded

print("loaded")

Frame.Visible = false

-- the game is loaded

1 Like

Im not sure why you would want to preload the game if you are making a custom loading screen?

It sort of Defeats the Purpose of even having it

Oh, I thought he meant an screen that actually loads the game. he can stick to yours then.

How come? the way this script works is the following: it loads the loading screen, then the game loads all the assets, and once its done loading all the assets, the loading screen is removed.

While true, most loading screens are used as a way to hide, and or give the illusion that something is happening due to having things the developers dont want the consumer to see.
Loading things are really fast as long as its efficient (eg: Something that does not take years to calculate) and not handling a billion things at once. One example of this when a loading screen trys to preload every single object in a for loop, when you can preload the entire workspace.

for _,v in workspace:GetDescendants() do
 ContentProvider:PreloadAsync({v})
end

-- What can be done instead:
ContentProvider:PreloadAsync{workspace}
-- PreloadAsync will automatically preload any descendants of an object in
-- the list, so the above would be unessecary for that reason

Is this a bad thing? No, some things need to occur in the background in order to ensure everything functions properly. However, the entire process (Loading things in a certain way) will Ultimately depend on how you create your game, and whether or not you need to do this. To each their own I say.

TLDR: It depends on how you code your game, from there you’ll have to decide if your game needs it, which is ultimately up to you.

1 Like