Expected Output:
The loading screen is supposed to fade out and destroy the clone of the loading screen from ReplicatedFirst when the game is done ‘loading’.
Output:
The background fades out, but the TextLabels don’t. The script also doesn’t destroy the LoadingScreen, so it remains in PlayerGui.
What I’ve Done:
I’ve searched all over for answers as to why this is happening, but I couldn’t find any.
Local Script (Controlling the Process:)
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local loadingScreen = script.LoadingScreen:Clone()
loadingScreen.Parent = playerGui
local background = loadingScreen.Background
local gameName = loadingScreen.GameName
local loading = loadingScreen.Loading
wait(10)
function fadeAll()
loading.TransparencyControl:Destroy()
wait(0.10)
while true do
wait(0.010)
background.Transparency = background.Transparency + 0.10
end
while true do
wait(0.010)
gameName.TextTransparency = gameName.Transparency + 0.10
end
repeat
wait(0.010)
loading.TextTransparency = loading.Transparency + 0.10
until loading.TextTransparency >= 1
end
fadeAll()
wait(0.10)
loadingScreen:Destroy()
Im confident the issue is in how you’re doing your loops. Why are you making a loop for each of the elements in your UI when they could all be in a single loop?
I didn’t think about that, also I don’t know how to break loops as I don’t know a lot of things about scripting. I tested each line and it turns out every time a loop is introduced the script stops. I’m probably going to make one loop for everything so it all goes transparent before it stops.
i think i actually know why you’re getting this wrong
youre assuming that if you do loops like these
while true do
--do something
end
while true do
--do some other thing
end
that they run simultaneously, but that is not the case. the code under the first loop will not run until the loop is broken.
another form of doing what youre tryna do is
while true do
gameName.TextTransparency += 0.10
if gameName.TextTransparency >=1 then break end --break ends the loop
wait(0.01)
end
loadingScreen:Destroy() --this wont run until BREAK