I’ve created a custom loading screen and would like to know what I could improve on. Please let me know!
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
local TweenService = game:GetService("TweenService")
local ContentProvider = game:GetService("ContentProvider")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local LoadingGui = script:WaitForChild("LoadingGui")
local GuiElements = {LoadingGui.MainFrame, LoadingGui.MainFrame.Logo}
local DetailCounters = {LoadingGui.MainFrame.Counters.Detail1, LoadingGui.MainFrame.Counters.Detail2, LoadingGui.MainFrame.Counters.Detail3, LoadingGui.MainFrame.Counters.Detail4, LoadingGui.MainFrame.Counters.Detail5,}
local AssetLoad = {game.Workspace:GetDescendants(), PlayerGui:GetDescendants(), game.ReplicatedStorage:GetDescendants()}
local LoadingCompleted = false
LoadingGui.Parent = PlayerGui
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
wait(1)
for i, Content in pairs(AssetLoad) do
for i = 1, #AssetLoad do
local Asset = Content[i]
ContentProvider:PreloadAsync({Asset})
local Progress = i / #AssetLoad * 100
local function Detail(Counter)
TweenService:Create(Counter, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false), {BackgroundColor3 = Color3.new(0, 0, 0)}):Play()
end
if Progress >= 20 then
Detail(DetailCounters[1])
if Progress >= 40 then
Detail(DetailCounters[2])
if Progress >= 60 then
Detail(DetailCounters[3])
if Progress >= 80 then
Detail(DetailCounters[4])
if Progress >= 100 then
Detail(DetailCounters[5])
wait(1)
LoadingCompleted = true
end
end
end
end
end
end
end
if LoadingCompleted == true then
for i, Counter in pairs(DetailCounters) do
TweenService:Create(Counter, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false), {BackgroundTransparency = 1}):Play()
end
TweenService:Create(GuiElements[2], TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false), {ImageTransparency = 1}):Play()
local MainTween = TweenService:Create(GuiElements[1], TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false), {BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647)})
MainTween:Play()
MainTween.Completed:Connect(function()
wait(1)
TweenService:Create(GuiElements[1], TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false), {BackgroundTransparency = 1}):Play()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, true)
end)
wait(3)
LoadingGui:Destroy()
script:Destroy()
end
Thanks,
Skylexion