-- Functions.

local function ResizeBar(percent)
	if screenVisible then
		inside:TweenSize(UDim2.new(percent, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear)
	end
end

local function hideLoadingScreen()
	if screenVisible then
		screenVisible = false
		ResizeBar(1)
		task.wait(1)
		clonedLoadingScreen.Frame:TweenPosition(UDim2.new(0,0,-1.5,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad, 1)
		clonedLoadingScreen:Destroy()
		game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
		game:GetService("TextChatService"):WaitForChild("ChatWindowConfiguration").Enabled = true
		game:GetService("TextChatService"):WaitForChild("ChatInputBarConfiguration").Enabled = true
		
		game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	end
end

coroutine.wrap(function()
	wait(hideAfter)
	ResizeBar(1)
	task.wait(1)
	hideLoadingScreen()
end)()
