Hello. I’m trying to make a loading screen that actually loads all the assets, but the loading screen doesn’t seem to show up. I also checked, and it doesn’t appear in my playerGui. I’ve tried fixing any mistake I made, but it still doesn’t work. Thanks for reading this.
Script:
local repfirst = game:GetService("ReplicatedFirst")
local contentprovider = game:GetService("ContentProvider")
local ts = game:GetService("TweenService")
local bgti = TweenInfo.new(1.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 0)
local barti = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local player = game:GetService("Players").LocalPlayer
local playergui = player:WaitForChild("PlayerGui")
local screen = script:WaitForChild("Loading")
repfirst:RemoveDefaultLoadingScreen()
local assets = game:GetDescendants()
local newscreen = screen:Clone()
newscreen.Parent = playergui
local background = newscreen:WaitForChild("Background")
local bar = newscreen:WaitForChild("LoadingBar")
local filler = bar:WaitForChild("ProgressBar")
local percent = bar:WaitForChild("Loading")
local texthandler = newscreen:WaitForChild("TextHandler")
local text = newscreen:WaitForChild("Loading")
for i = 1, #assets do
local asset = assets[i]
print(#assets)
local loadedpercent = math.round(i/#assets * 100)
contentprovider:PreloadAsync({asset})
percent.Text = loadedpercent .. "%"
local bartween = ts:Create(filler, barti, {Size = UDim2.fromScale(loadedpercent/100, 1)})
bartween:Play()
if i == #assets then
texthandler:Destroy()
text.Text = "Loading Finished!"
local blur = Instance.new("BlurEffect")
blur.Parent = game:GetService("Lighting")
blur.Size = 9
local bgtween = ts:Create(background, bgti, {Transparency = 1})
task.wait(2.5)
bgtween:Play()
bgtween.Completed:Wait()
end
end