I’ve encountered another bug for my grand-strat game.
The bug I’m unable to fix here is the loading screen not destroying itself when all assets have been loaded. LoadingPhase()
doesn’t stop on command or automatically and the screen just stays in place. However if I cancel out this function it destroys itself as expected.
Why is this? And… can someone help me fix this as well as synchronizing LoadingExit()
(funct that fades away loading screen details for cool transition)? [I actually want to make way for my intro and credit screens but for now I want the UI to destroy itself first before I can configure the other screens]
With LoadingPhase()
Without LoadingPhase()
local contentProvider = game:GetService("ContentProvider")
local ui = script:WaitForChild("loading screen"):Clone()
repeat wait() until game:IsLoaded()
local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
local loadingtextlabel = ui:WaitForChild("Frame"):WaitForChild("loadingtextlabel")
local TextLabel = ui:WaitForChild("Frame"):WaitForChild("TextLabel")
local loadingtextlabelVN = ui:WaitForChild("Frame"):WaitForChild("loadingtextlabelVN")
local clockimg = ui:WaitForChild("Frame"):WaitForChild("clockimgrnumerals")
local nhac_bao_gio = game.Workspace.soundsfolder.nhac_bao_gio
TextLabel.Visible = true
TextLabel.TextTransparency = 0
local function LoadingPhase()
loadingtextlabelVN.Visible = true
loadingtextlabel.Visible = true
clockimg.Visible = true
for i = 1, 0, -0.02 do
wait(0.01)
loadingtextlabel.TextTransparency = i
loadingtextlabelVN.TextTransparency = i
clockimg.ImageTransparency = i
TextLabel.TextTransparency = i
end
loadingtextlabel.TextTransparency = 0
clockimg.ImageTransparency = 0
loadingtextlabelVN.TextTransparency = 0
nhac_bao_gio:Play()
while true do
loadingtextlabel.Text = "LOADING GAME."
wait(0.4)
loadingtextlabel.Text = "LOADING GAME.."
wait(0.4)
loadingtextlabel.Text = "LOADING GAME..."
wait(0.4)
end
end
local function LoadingExit()
for i = 0, 1, 0.02 do
wait(0.01)
loadingtextlabel.TextTransparency = i
loadingtextlabelVN.TextTransparency = i
clockimg.ImageTransparency = i
TextLabel.TextTransparency = i
end
loadingtextlabel.TextTransparency = 1
clockimg.ImageTransparency = 1
loadingtextlabelVN.TextTransparency = 1
TextLabel.TextTransparency = 1
nhac_bao_gio:Stop()
end
local assets = game:GetDescendants()
local maxAssets = #assets
ui.Parent = plrGui -- LOADING BEGINS
ui:WaitForChild("Frame"):WaitForChild("TextLabel").Text = "0/"..maxAssets
wait(1)
for i, assetToLoad in assets do
contentProvider:PreloadAsync({assetToLoad})
ui:WaitForChild("Frame"):WaitForChild("TextLabel").Text = i.."/"..maxAssets
end
-- LoadingPhase()
-- LoadingExit()
wait(1)
ui:Destroy() -- LOADING ENDS
For now I’ve disabled both since I’m unsure but I suspect it’s the while true do
loop within LoadingPhase()
that’s causing this (aka holding the ui:Destroy()
hostage)