Hello,
I am trying to create a loading bar that works but for some reason it does never load. I believe this is due to game.Loaded:Wait(). For some reason when I put a print under it does not print out but when I do it above it does print.
If I am going around this the incorrect way could someone point me into the correct direction.
Code:
local contenProvider = game:GetService("ContentProvider")
local UI = script.Parent.Parent
local LoadingBar = script.Parent.BarBackground.Bar
local Skip = false
game.Loaded:Wait()
local ThingsToLoad = workspace:GetDescendants()
local total = #ThingsToLoad
print(#ThingsToLoad)
script.Parent.Skip.MouseButton1Click:Connect(function()
Skip = true
end)
for i,v in pairs(ThingsToLoad) do
print(v)
if Skip == false then
LoadingBar.Size = UDim2.new(i/total, 0, 1, 0)
contenProvider:PreloadAsync({v})
else
UI.Enabled = false
break
end
end
wait(1)
UI.Enabled = false