-- Animate the Background

local function imageTween(whenTweenCompleted)
	clonedLoadingScreen.Frame.Pattern:TweenPosition(UDim2.new(1, 0, 0.5, 0), "Out", "Linear", 20, false, whenTweenCompleted)
end
local function whenTweenCompleted(state)
	if state == Enum.TweenStatus.Completed then	
		clonedLoadingScreen.Frame.Pattern.Position = UDim2.new(0, 0, 0.5, 0)
		imageTween(whenTweenCompleted)
	end
end
imageTween(whenTweenCompleted)

skipButton.MouseButton1Down:Connect(function()
	hideLoadingScreen()
end)



frame.Visible = true

local Assets = game:GetDescendants()

local startTime = os.clock()

for i = 1, #Assets do
	local asset = Assets[i]
	ContentProvider:PreloadAsync({asset})
	loadingPercentage.Text = "Loading experience - " ..i.. "/" ..#Assets
	ResizeBar(i/#Assets)
end

hideLoadingScreen()

local deltaTime = os.clock() - startTime
print(("Loading complete, time: %.2f"):format(deltaTime))
