Loading Screen Won't Function

I am a VERY new scripter, but I wanted to make an introduction GUI for my game. After digging around YouTube, I found absolutely no help whatsoever, so I turned to good old-fashioned “let’s see what I know”.
Turns out, not much. My script is supposed to wait 10 seconds before replacing a “Loading Assets…” title with “Assets Loaded.”, then destroying itself, but it doesn’t seem to be working.

As a naive scripter, I thought this to be the perfect place to get some help.

script.Parent:RemoveDefaultLoadingScreen()

local GUI = script.StarterScreen
GUI.Parent = game.Players.LocalPlayer.PlayerGui

wait(10)
GUI.Background.Counter.Text = "Assets Loaded."
wait(1)
GUI:Destroy()

image_2022-05-15_021047684

1 Like

You must put script in ReplicatedFirst

It is already inside of ReplicatedFirst
image_2022-05-15_023511543

script.Parent:RemoveDefaultLoadingScreen()

local GUI = script.StarterScreen
local CloneGUI = GUI:Clone()

CloneGUI.Parent = game.Players.LocalPlayer.PlayerGui

wait(10)
CloneGUI.Background.Counter.Text = "Assets Loaded."
wait(1)
CloneGUI:Destroy()

I prefer you to use PreloadAsync that actually loads assets, instead of adding wait.

It worked, but the GUI only stayed for half a second. Do you know how to get around that? Because the script is supposed to make the loading screen stay for 10 seconds, but it doesnt.

Then the GUI stays for a very short time, and I wish to keep it for at least 8-10 seconds.

I know. But we talking about why this not work.

See I told you, whenever player is loading while in the loading screen if the time took 10 seconds for that player to load then they will not see any gui at all since its already loaded.

And you can load the important things you wanna load using PreloadAsync

I am confused. The script is supposed to eliminate the default loading screen, then make the custom GUI stay for 10 seconds. I don’t see what you are getting at, could you elaborate further?

I think we will have to try this script I’m not sure

@fergusnoot I highly recommend using task.wait instead of wait as it is much more optimized. Also, put it in startergui and see what happens, since replicatedfirst loads really quick, so waiting 10 seconds might not be enough.

And if the GUI appears when you put it in there make it disabled and then enable it via the script.
Like so:

image

-- Put this after you say what the GUI is.
GUI.Enabled = true

So, this?

script.Parent:RemoveDefaultLoadingScreen()

local GUI = script.StarterScreen
GUI.Parent = game.Players.LocalPlayer.PlayerGui
GUI.Enabled = true

task.wait(10)
GUI.Background.Counter.Text = "Assets Loaded."
task.wait(1)
GUI:Destroy()```
1 Like

Yes, that should work.

local cp = game:GetService("ContentProvider")
script.Parent:RemoveDefaultLoadingScreen()

local GUI = script.StarterScreen
local CloneGUI = GUI:Clone()

CloneGUI.Parent = game.Players.LocalPlayer.PlayerGui

for i,v in pairs(workspace:GetChildren()) do
   cp:PreloadAsync({v})
end

-- once loops ends it will put "Assets loaded" in the counter

CloneGUI.Background.Counter.Text = "Assets Loaded."
wait(1)
CloneGUI:Destroy()

If thats taking too long then put the important things you want to load first in the for loop.

2 Likes

Also, for the 342357th time, you should use task.wait() since it’s more optimized. And instead of straight up destroying the GUI you should tween (animate) it:

-- You can mess around with the parameters
GUI.Background:TweenPosition(UDim2.new(0,0,1,0))

Well first, lets focus on the problem :smiley:

1 Like

It’s usually a better idea to put it in replicated first, because (as the name suggests) it is created first, being one of the first things to be created, it will also be the first thing the player sees.

Now, this is a pretty good way to make a loading screen. However, sometimes the assets load rather fast, resulting in a short loading screen. For UX sake, you may want to add a custom wait for it to feel more satisfying.

TL;DR:

In short, keep your loading screen in ReplicatedFirst, preload your assets (if desired), and add a short task.wait, all before removing the loading screen.

So, this is pretty confusing, because now I have ended up with this final product of a mess that doesn’t work and I am literally just about to give up. Was my original code correct or incorrect?
CURRENT:

local cp = game:GetService("ContentProvider")
script.Parent:RemoveDefaultLoadingScreen()

local GUI = script.StarterScreen
local CloneGUI = GUI:Clone()
GUI.Enabled = true

CloneGUI.Parent = game.Players.LocalPlayer.PlayerGui

for i,v in pairs(workspace:GetChildren()) do
	cp:PreloadAsync({v})
end

-- once loops ends it will put "Assets loaded" in the counter

CloneGUI.Background.Counter.Text = "Assets Loaded."
wait(1)
CloneGUI:Destroy()

Utter confusion, everybody suggesting all these different edits has got me dead in a ditch

Normal Script in ReplicatedFirst [NOT LOCAL SCRIPT]

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

Put GUI in ServerStorage

Put script in ServerScriptService:

game.Players.PlayerAdded:Connect(function(player)
	game.ServerStorage.LoadingGui:Clone().Parent  = player.PlayerGui
end)

LocalScript in GUI [Part of My game script]

local ReplicatedFirst = game:GetService("ReplicatedFirst")

local LoadingLabel = script.Parent.LoadingScreen.LoadingText
local LoadText = script.Parent.LoadingScreen.LoadingNameText

local Loaded = game:IsLoaded() or game.Loaded:Wait()

local ContentProvider = game:GetService('ContentProvider')

if Loaded then
	wait(3)
	for i,v in pairs(workspace:GetChildren()) do
		LoadingLabel.Text = v.Name
		ContentProvider:PreloadAsync({v})
		wait(.01)
	end
	
end

LoadText.Text = "Loaded!"

wait(2)


script.Parent.LoadingScreen.Parent:Destroy()

1 Like