Loading Screen won't show up

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make my loading screen gui work for Kings Landing…
  2. What is the issue? Include screenshots / videos if possible!
    Loading won’t work alongside the cutscene, and no one is willing to help me fix my loadlibrary cutscene part in the script as well…
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried HttpService for Cutscene script, and rbx utility and so on… but no work, and there isn’t an error or an issue within the LocalScript for the LoadingScreen Menu gui.
Script:
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
repeat wait() until Player.PlayerGui:FindFirstChild("ControlGui")
Player.PlayerGui.ControlGui.BottomLeftControl.Visible = false

local Interface = PlayerGui:WaitForChild("Interface")
Interface.Enabled = false

PlayerGui:SetTopbarTransparency(0)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)

local CutsceneScript = script:WaitForChild("CutsceneScript")
CutsceneScript.Parent = PlayerGui

local Blur = Instance.new("BlurEffect",game.Lighting)
Blur.Size = 15

local LoadingScreen = script.Parent
local MainFrame = LoadingScreen:WaitForChild("MainFrame")
MainFrame.Visible = true
local LoadBarHolder = MainFrame:WaitForChild("LoadBarHolder")
local LoadBar = LoadBarHolder:WaitForChild("LoadBar")
local LoadingText = MainFrame:WaitForChild("LoadingText")
local GameNameText = MainFrame:WaitForChild("LoadingGameName")
local Music = LoadingScreen:WaitForChild("Music")
local Menu = LoadingScreen:WaitForChild("Menu")
local PlayButton = Menu:WaitForChild("PlayButton")

local GameMusic = workspace:WaitForChild("Mechanics"):WaitForChild("Sounds"):WaitForChild("Music")
GameMusic.Volume = 0

local LoadTime = 45

LoadBar:TweenSize(UDim2.new(1,0,1,0),"Out","Quad",LoadTime)

wait(LoadTime)

for i = 0,1,.1 do
	LoadingText.TextTransparency = i
	wait(.01)
end

LoadingText.Text = "- Loaded -"

for i = 1,0,-.1 do
	LoadingText.TextTransparency = i
	wait(.01)
end

for i,v in pairs(MainFrame:GetChildren())do
	if v.Name ~= "LoadingGameName" then
		if v.Name == "LoadingText" then
			v:TweenPosition(UDim2.new(v.Position.X.Scale,v.Position.X.Offset,-1,0),"Out","Quad",2)
		else
			v:TweenPosition(UDim2.new(v.Position.X.Scale,v.Position.X.Offset,1.5,0),"Out","Quad",2)
		end
	end
end

for i = 0,1,.1 do
	GameNameText.TextTransparency = i
	wait(.01)
end

GameNameText.Text = "Welcome to King's Landing!"

for i = 1,0,-.1 do
	GameNameText.TextTransparency = i
	wait(.01)
end

wait(3)

CutsceneScript.Disabled = false

for i = 0,1,.1 do
	GameNameText.TextTransparency = i
	wait(.01)
end

Music:Play()
wait(.2)
MainFrame.Visible = false
Menu.Visible = true
wait(5)
Menu.PlayButton.Visible = true
for i = 1,0,-.01 do
	Menu.PlayButton.TextTransparency = i
	Menu.PlayButton.BackgroundTransparency = i
end
PlayButton.MouseButton1Down:connect(function()
	local Camera = game.Workspace.CurrentCamera
	
	Menu:TweenPosition(UDim2.new(.5,0,-1,0),"Out","Quad",2)
	
	wait(2.5)
	
	Blur:Destroy()
	CutsceneScript:Destroy()
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = Player.Character.Humanoid
	Camera.FieldOfView = 70
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
	PlayerGui:SetTopbarTransparency(.5)
	
	for i = 1,0,-.01 do
		Music.Volume = i
		wait(.01)
	end		
	
	for i = 0, .2,.01 do
		GameMusic.Volume = i
		wait(.01)
	end

	wait(1)
	LoadingScreen:Destroy()
	
	
	Interface.Enabled = true
end)
1 Like

And you are sure there are no warning logs for a variable that is still yielding because the associated object does not exist?

There’s no warnings or errors within the script analysis logs…

Where does this script exist? Is it inside a GUI inside startergui?


https://gyazo.com/b25f3ded675df1576187188cf467c7f6

Yes, those are located within the StarterGui.

Can you try adding print statements before and after the repeat wait() section and tell me if it prints?

Okay, so I’ve added this:


Only one of them printed…

That means ControlGui is not a valid member of your playergui and thus it hangs forever


https://gyazo.com/82105904e216b37bfe76df5658e9e1d5

after it printed ^

Do you have another script that touches the “ControlGui”? If no, make sure it is a part of StarterGui

Yeah, I don’t believe there is.

I do not see a ControlGui object there. That is why it is hanging, and also why your other script wont work.

Is it possible you could re code it for me on that part then?

remove this

repeat wait() until Player.PlayerGui:FindFirstChild("ControlGui")
Player.PlayerGui.ControlGui.BottomLeftControl.Visible = false

Is that all I have to do for the script?

Yes. Also make sure to do the HTTP JSONDecode that I posted in your other thread. Then run it and let me know if there are any errors.

I did the thing you told me to remove, and now its loading the loading gui correctly, and the cutscene is also working correctly. Thanks for helping me sir, I appreciate the help in the community.

2 Likes

I know I’m a bit late but and this has allready been solved but here is some advice to improve your script

1. Use Tweens instead of for loops
-- Tween TextTransparency To 1
ts:Create(LoadingText, tweeninfo, {TextTransparency = 1}):Play()

-- Tween TextTransparency To 0
ts:Create(LoadingText, tweeninfo, {TextTransparency = 0}):Play()

-- Tween BackgroundTransparency To 1
ts:Create(Menu.PlayButton, tweeninfo, {BackgroundTransparency = 1}):Play()

-- Tween BackgroundTransparency To 0
ts:Create(Menu.PlayButton, tweeninfo, {BackgroundTransparency = 0}):Play()

-- Tween Volume To 1
ts:Create(Music, tweeninfo, {Volume = 1}):Play()

-- Tween Volume To 0
ts:Create(Music, tweeninfo, {Volume = 0}):Play()
2. Dont use wait(n) is bad
local Heartbeat = game:GetService("RunService").Heartbeat

-- Use This Instead
local function accurateWait(n)
	local elapsed = 0
	while elapsed < n do
		elapsed = elapsed+Heartbeat:Wait()
	end
	return elapsed
end

Avoiding wait() and why