I have been trying to make a loading screen on Roblox which loads assets and displays a % on a loading a bar. It also replaces the default screen,
The script and screen are within ReplicatedFirst
The issue is that the bar/assets and the percentage are simply not changing.
https://gyazo.com/03bccc400acc8eb6ac1bf64668222068
I have tried looking for solutions on the forums and hub with little to no help.
This is the code ;
local replicatedfirst = game:GetService("ReplicatedFirst")
local contentprovider = game:GetService("ContentProvider")
local tweenservice = game:GetService("TweenService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")
local loadingscreen = script:WaitForChild("LoadingScreen")
replicatedfirst:RemoveDefaultLoadingScreen()
local assets = game:GetDescendants()
local clonedLoadingScreen = loadingscreen:clone()
clonedLoadingScreen.Parent = playergui
for i = 1, #assets do
local asset = assets[i]
local percentage = math.round(i / assets * 100)
contentprovider:PreloadAsync({asset})
clonedLoadingScreen.Background.DisplayPercentage.Text = percentage.."%"
clonedLoadingScreen.Background.DisplayAssetsLoaded.Text = "Loading Assets: "..i.."/"..#assets
tweenservice:Create(clonedLoadingScreen.Background.BarBackground.Bar.Size, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, {Size = UDim2.fromScale(percentage/100)}))
if i % 5 == 0 then
task.wait()
end
if i == #assets then
task.wait(1)
end
end
