How do i make a loading screen?

i want to make a loading screen for my game but i don’t know how. this is what i have so far:

local gui = script:WaitForChild("Loading"):Clone()
local content = game:GetService("ContentProvider")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
ReplicatedFirst:RemoveDefaultLoadingScreen()
local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
script.Loading.LoadingScreen.Visible = true
gui.Parent = plrgui
	local Player = game.Players.LocalPlayer
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid")
    local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
if not game:IsLoaded() then
	game.Loaded:Wait()
	Humanoid.WalkSpeed = 0
	HumanoidRootPart.Anchored = true
	else
	Humanoid.WalkSpeed = 16
	HumanoidRootPart.Anchored = false
	plrgui.Loading:Destroy()
	
end
for i = 1, #assets do
	local asset = assets[i]
	content:PreloadAsync({asset})
	gui:WaitForChild("LoadingScreen"):WaitForChild("LoadStatus").Text = "Loading: " ..asset.Name.. " [" .. i .. "/" .. #assets .. "]"
end

this script is in replicated storage alongside with the loading screen itself.
this game is a single player horror game. my loading screen is basic, just black background with the asset loading name.

Update: please look at @GolgiToad’s posts.

1 Like

Put a script in StarterPlayerScripts, then get the RepicatedFirst Property, then make a textlabel with these properties (Make a screenGUI first)

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local player = Players.LocalPlayer
local playerGUI = player:WaitForChild("PlayerGui")

local ScreenGui = Instance.new("ScreenGui")
ScreenGui.IgnoreGuiInset = true

local TextLabel = Instance.new("TextLabel",ScreenGui)
TextLabel.Size = UDim2.new(1,0,1,0)
TextLabel.BackgroundColor3 = Color3.new(0, 0, 0)
TextLabel.Text = "Loading, please wait..."
TextLabel.Font = Enum.Font.Arcade
TextLabel.TextSize = 28
TextLabel.TextStrokeTransparency = 0
TextLabel.TextColor3 = Color3.new(1, 1, 1)
ScreenGui.Parent = playerGUI

Remove the default loading screen

ReplicatedFirst:RemoveDefaultLoadingScreen()

Then wait for the game to load.

wait(7) -- Maybe make the loading screen be on there for a few seconds first (Optional)

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

Then make everything dissapear

TextLabel.Text = "Done!"
wait(1)

BackGroundFrame.BackgroundTransparency = 0
BackGroundFrame:WaitForChild("HPBarDisplay").BackgroundTransparency = 0 
BackGroundFrame:WaitForChild("Health").TextTransparency = 0

Timer.BackgroundTransparency = 0
Timer.TextTransparency = 0

game:GetService("Debris"):AddItem(ScreenGui,0)
2 Likes

Hello i made a tutorial of how to script a real loading screen in my yt channel (free model in description)

2 Likes

You should use preloadasync too and plz dont use wait it is outdated.

sorry for asking, but what is wrong with this:

local gui = script:Clone()

local ReplicatedFirst = game:GetService(“ReplicatedFirst”)

ReplicatedFirst:RemoveDefaultLoadingScreen()

local plr = game.Players.LocalPlayer

local plrgui = plr.PlayerGui

script.Loading.LoadingScreen.Visible = true

local Jump = game.StarterPlayer

local Running = game.StarterGui:WaitForChild(“RunningScript”)

Running.Disabled = true

gui.Parent = plrgui

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Humanoid = Character:WaitForChild(“Humanoid”)

local HumanoidRootPart = Character:WaitForChild(“HumanoidRootPart”)

if not game:IsLoaded() then

game.Loaded:Wait()

Humanoid.WalkSpeed = 0

HumanoidRootPart.Anchored = true

Running.Disabled = true else

Humanoid.WalkSpeed = 16

Running.Disabled = false

HumanoidRootPart.Anchored = false

plrgui.Loading:Destroy()

end

the screen doesn’t go away but i think everything works because i can hear myself walking.

1 Like

Hello, the problem is you don’t preload the game assets using Preloadasync.
and in my tutorial screen self destruct after the finish.

How do I do that exactly? I didn’t quite understand. I’m pretty new to scripting. Your script did put me on the right path though.

1 Like

Ops now i find a bug in your script you are using script:Clone() not script:WaitForChild(“Loading”):Clone()

hope I helped – paulocezarnbr
Subscribe and comment on more tutorials I should do! :wink:

Thanks! I’ll test tomorrow because I’ll have to go to sleep because school.

Ok, good night if this doesn’t work you can take my free model from Youtube.

1 Like

the issue here is you are doing it cliently for all starter guis and not for player uis

this is the part where it should not be game.StarterGui but
finding the UI in the player GUI

1 Like

I’m not sure what you mean. That’s a variable of my running script which is in startergui.

game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("RunningScript")

i think it might actually work! i will test now in roblox because it loads too fast in studio. nevermind.

1 Like

i decided to just change your UI and change it. i’ll disable movement now. thank you.

1 Like

Using your code as a start, but one critique. By the time the first asset is loaded, my progress meter is already at 900/2900. Have you messed around with coroutines to make the counter start at 1? I don’t want people sitting around for a minute wondering what happened (they have a slow machine).

I’ll give this a try, but curious if you have had this issue.

1 Like

Here is my attempt, but weird things happened:

local loadCount = 0

for i = 1, #assets do
	coroutine.wrap(function ()
		local asset = assets[i]
		contentprovider:PreloadAsync({asset})
		loadCount += 1
		loadStatus.Text = "Loading: " ..asset.ClassName .. " [" .. loadCount .. "/" .. #assets .. "]"
	end)()
end

repeat task.wait() until #assets == loadCount

The count started at 2930, not 900, as almost all the assets loaded immediately. I don’t know if that is good or bad. Also, I got a record gameload time. That certainly wasn’t intentional! I could also see that the slowest loading asset is the StarterGUI, so I might be able to improve that even more.

Anyway, dropped some code in here for anyone looking for solutions! Thanks again!

3 Likes