hello, im wondering why my script sometimes work while other times it doesn’t
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
task.wait(1)
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local LoadingScreen = script:WaitForChild("Gui"):Clone()
LoadingScreen.Name = "LoadingScreen"
LoadingScreen.Parent = PlayerGui
LoadingScreen:WaitForChild("LoadingGui"):WaitForChild("PlaceVersion").Text = "Place Version: " .. game.PlaceVersion
local ContentProvider = game:GetService("ContentProvider")
local AssetsToLoad = game:GetDescendants()
local Total = #AssetsToLoad
local Loaded = 0
for i,v in pairs(AssetsToLoad) do
Loaded += 1
LoadingScreen:WaitForChild('LoadingGui').Amount.Text = i .. "/" .. Total
LoadingScreen:WaitForChild("LoadingGui"):WaitForChild("Percent").Text = math.floor((Loaded / Total) * 100) .. "%"
LoadingScreen:WaitForChild("LoadingGui").LoadingBar.Bar:TweenSize(UDim2.new(i/Total, 0, 1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.25, true)
ContentProvider:PreloadAsync({v})
end
task.wait(1.25)
LoadingScreen:WaitForChild("LoadingGui"):TweenPosition(UDim2.new(0,0,1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5, true, function()
LoadingScreen:Destroy()
end)
any help is appreciated! if you have any questions then dont feel afraid to ask!